Bitwise is a designating operator in a programming language that manipulates the individual bits in a byte or word. This is very rarely used in programming, but if you can figure it out, maybe it can be your shortcut in getting something done
Cheat Sheet
Operator | Description |
& | AND example: a & b Returns one at each bit position where the bit The corresponding value of both operands is one. |
| | OR example: a | b Returns one at each bit position where the corresponding bit of either or both operands is one. |
^ | XOR example: a ^ b Returns one at each bit position where the corresponding bit of is false one but not both operands are one. |
~ | NOT example: ~a Inverts the bits of the operand. |
Left Shift a Shifts a in binary representation b ( | |
>> | Signpropagating right shift a >> b Shift a in binary representation b ( |
Example of Use
if the snippet below doesn't work, please open this snippet