diff options
| author | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-06 00:17:59 +0200 |
|---|---|---|
| committer | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-06 00:17:59 +0200 |
| commit | 442921c7bd93e9e111845de6c22f66753b41e11a (patch) | |
| tree | be6c168303240c168def228c763614d3a9d1c91e /other/bitOps.cpp | |
| parent | 7c97303ec8fc5dfc278198687d8c5154e0cd1baf (diff) | |
Renamin sonstiges ot other.
Diffstat (limited to 'other/bitOps.cpp')
| -rw-r--r-- | other/bitOps.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/other/bitOps.cpp b/other/bitOps.cpp new file mode 100644 index 0000000..b75304f --- /dev/null +++ b/other/bitOps.cpp @@ -0,0 +1,14 @@ +// Bit an Position j auslesen. +(a & (1 << j)) != 0 +// Bit an Position j setzen. +a |= (1 << j) +// Bit an Position j löschen. +a &= ~(1 << j) +// Bit an Position j umkehren. +a ^= (1 << j) +// Wert des niedrigsten gesetzten Bits. +(a & -a) +// Setzt alle Bits auf 1. +a = -1 +// Setzt die ersten n Bits auf 1. Achtung: Overflows. +a = (1 << n) - 1 |
