diff options
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 |
