From 9e625b89bac7e8daaf583e215f3a0df3dc250bb2 Mon Sep 17 00:00:00 2001 From: Paul Jungeblut Date: Mon, 27 Jun 2016 11:17:34 +0200 Subject: Math section rebuild, merged convinience and sonstiges section. --- sonstiges/bitOps.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'sonstiges/bitOps.cpp') 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 -- cgit v1.2.3