From ac2c261f2c662f021c1016f18998a621c3ba0eaa Mon Sep 17 00:00:00 2001 From: pjungeblut Date: Tue, 25 Nov 2014 22:54:57 +0100 Subject: bits --- sonstiges/bitOps.cpp | 23 ++++++++--------------- tcr.pdf | Bin 204181 -> 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 Binary files a/tcr.pdf and b/tcr.pdf differ -- cgit v1.2.3