summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpjungeblut <paul.jungeblut@gmail.com>2014-11-25 22:54:57 +0100
committerpjungeblut <paul.jungeblut@gmail.com>2014-11-25 22:54:57 +0100
commitac2c261f2c662f021c1016f18998a621c3ba0eaa (patch)
treea839c7910c4abf1aa19d196fa6be885ca8d7432d
parent3e4cca763aad161d84e524502605239487ccbf8e (diff)
bits
-rw-r--r--sonstiges/bitOps.cpp23
-rw-r--r--tcr.pdfbin204181 -> 204053 bytes
2 files changed, 8 insertions, 15 deletions
diff --git a/sonstiges/bitOps.cpp b/sonstiges/bitOps.cpp
index 20ca532..b882965 100644
--- a/sonstiges/bitOps.cpp
+++ b/sonstiges/bitOps.cpp
@@ -1,22 +1,15 @@
-// [lsb: 0-th bit, msb: n-th bit,]
-
-//Get j-th bit:
+//lsb: 0-th bit, msb: n-th bit
+//get j-th bit
(a & (1 << j)) != 0
-
-//Set j-th bit:
+//set j-th bit
a |= (1 << j)
-
-//Clear j-th bit:
+//clear j-th bit
a &= ~(1 << j)
-
-//Toggle j-th bit:
+//toggle j-th bit
a ^= (1 << j)
-
-//Get value of first set bit:
+//get value of least significant bit set
(a & -a)
-
-//Turn on all bits:
+//turn on all bits
a = -1
-
-//Turn on first n bits:
+//turn on first n bits (be aware of overflows)
a = (1 << n) - 1
diff --git a/tcr.pdf b/tcr.pdf
index 0778bd6..06664a8 100644
--- a/tcr.pdf
+++ b/tcr.pdf
Binary files differ