summaryrefslogtreecommitdiff
path: root/sonstiges/bitOps.cpp
diff options
context:
space:
mode:
authorPaul Jungeblut <paul.jungeblut@gmail.com>2016-06-27 11:17:34 +0200
committerPaul Jungeblut <paul.jungeblut@gmail.com>2016-06-27 11:17:34 +0200
commit9e625b89bac7e8daaf583e215f3a0df3dc250bb2 (patch)
treeab295455fce73f726bd97a325a61d95aca77a508 /sonstiges/bitOps.cpp
parent5bb1ac05882e0df43a2afe0c363e0f503f51c357 (diff)
Math section rebuild, merged convinience and sonstiges section.
Diffstat (limited to 'sonstiges/bitOps.cpp')
-rw-r--r--sonstiges/bitOps.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/sonstiges/bitOps.cpp b/sonstiges/bitOps.cpp
index b882965..b75304f 100644
--- a/sonstiges/bitOps.cpp
+++ b/sonstiges/bitOps.cpp
@@ -1,15 +1,14 @@
-//lsb: 0-th bit, msb: n-th bit
-//get j-th bit
+// Bit an Position j auslesen.
(a & (1 << j)) != 0
-//set j-th bit
+// Bit an Position j setzen.
a |= (1 << j)
-//clear j-th bit
+// Bit an Position j löschen.
a &= ~(1 << j)
-//toggle j-th bit
+// Bit an Position j umkehren.
a ^= (1 << j)
-//get value of least significant bit set
+// Wert des niedrigsten gesetzten Bits.
(a & -a)
-//turn on all bits
+// Setzt alle Bits auf 1.
a = -1
-//turn on first n bits (be aware of overflows)
+// Setzt die ersten n Bits auf 1. Achtung: Overflows.
a = (1 << n) - 1