in case you don't know anything about binary numbers
1 decimal = 1 binary
2 decimal = 10 binary
4 decimal = 100 binary
8 decimal = 1000 binary
if you shift left by 1 is the same as multiplying by 2
if you shift right by 1 is the same as divide by 2
to operate on two binary numbers :
"and" symbol "&". say 4 & 8 = 00:
0100 -> 4
1000 -> 8
------
0000 ->00 result
"or " symbol "|". say 4 | 8 = 12:
0100 -> 4
1000 -> 8
------
1100 -> 12 result
exclusiveor symbol "~". say 5~9
0101 -> 5
1001 -> 9
------
1100 ->12
if you want to find out if a certain bit in a variable is on or off then you would compare it with an "&". Say you don't know the third bit in x is on or of. then you would compare it with 4. If it is on, it will return 4 else it will return 0.
example 1:
if x = 13
x & 4 =
1101 -> x and is equal 13
0100 -> 4
------
0100 -> answer is 4
if you shift all the bits right by 2 then you get:
answer shr 2 = 0001 or 1 decimal
example 2:
if x = 13
x & 2 =
1101 -> x and is equal 13
0010 -> 2
------
0000 -> answer is 0
then shift answer 2:
answer shr 2 = 0000 -abvious answer.
if you want to extract more than 1 bit. say the third and second.
if x = 13
1101 -> x = 13
0110 -> 6
--------
0100 -> 8 answer
answer shr 1 = 4
<note> keep in mind this only works with integer variables. integers in bmax are 32 bits long (I believe). Both operands may be variables.