diff options
| author | Paul Jungeblut <s_jungeb@i08pc54.atis-stud.uni-karlsruhe.de> | 2014-11-25 17:48:20 +0100 |
|---|---|---|
| committer | Paul Jungeblut <s_jungeb@i08pc54.atis-stud.uni-karlsruhe.de> | 2014-11-25 17:48:20 +0100 |
| commit | 69d0ac7c81eed0c9ceaf1f19d9dcfbe2431ba55c (patch) | |
| tree | c19a4b84b242d3817d5d634dd6c69589c8c32669 /sonstiges/bitOps.cpp | |
| parent | 24a946fdaeb0e5ceabf458007128df4fd4872733 (diff) | |
Kombinatorik fertig
Diffstat (limited to 'sonstiges/bitOps.cpp')
| -rw-r--r-- | sonstiges/bitOps.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sonstiges/bitOps.cpp b/sonstiges/bitOps.cpp index df8cd8f..20ca532 100644 --- a/sonstiges/bitOps.cpp +++ b/sonstiges/bitOps.cpp @@ -1,22 +1,22 @@ -[lsb: 0-th bit, msb: n-th bit,] +// [lsb: 0-th bit, msb: n-th bit,] -Get j-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 first set bit: (a & -a) -Turn on all bits: +//Turn on all bits: a = -1 -Turn on first n bits: +//Turn on first n bits: a = (1 << n) - 1 |
