chess:programming:bit_operations
This is an old revision of the document!
Chess - Programming - Bit Operations
Expression | Description | Example |
---|---|---|
x & y | AND the bits of x with those of y | 21 & 7 = 10101 & 00111 = 00101 = 5 |
x | y | OR the bits of x with those of y | 21 | 7 = 10101 | 00111 = 10111 = 23 |
x ^ y | XOR the bits of x with those of y | 21 ^ 7 = 10101 ^ 00111 = 10010 = 18 |
~x | Inverting (complementing) the bits of x (0 → 1 and 1 → 0) | ~7 = 11111111111111000 = 65528 |
x « y | Shift the bits of x to the left y positions | 25 « 3 = 10101 « 3 = 10101000 = 168 |
x » y | Shift the bits of x to the right y positions | 25 » 3 = 10101 » 3 = 00010 = 2 |
chess/programming/bit_operations.1635939991.txt.gz · Last modified: 2021/11/03 11:46 by peter