Repo dedicated to notes on bitwise operators & direct bits manipulation
the EISA EDID edition tool is not yet written, only one helper that generates a valid manufacturer name from 3 chars
https://cdn.rawgit.com/stephaneAG/BitsOps/master/encoderDecoderWip.html R: to update it: https://developer.mozilla.org/en-US/docs/Web/API/Blob
- http://graphics.stanford.edu/~seander/bithacks.html
- http://www.catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/
_ & - bitwise and
_ | - bitwise or
_ ^ - bitwise xor
_ ~ - bitwise not
_ << - bitwise shift left unsigned
_ >> - bitwise shift right unsigned
_ >>> - bitwise shift right signed
_ 0x.. - hex / base 16
_ 0b.. - bin / base 2
(x>>n) & 1
if ((x & 1) == 0) {
// even
}
else {
// is odd
}
y = x | (1<<n)
y = x & ~(1<<n)
y = x ^ (1<<n)
if (x & (1<<n)) {
// n-th bit is set
}
else {
// n-th bit is not set
}
// or
(x & (1<<n) != 0) ? 'set' : 'not set'
y = x & (x-1)
y = x | (x+1)
y = x & (-x)
y = ~x & (x+1)
y = x | (x-1)