& bitwise AND. Given two bits for inputs, the following gives a bit output bitwise AND:
0 & 0 = 0 0 & 1 = 0 1 & 0 = 0 1 & 1 = 1
In this case
7 in binary is 00000111 8 in binary is 00001000 -------- 00000000, which is 0 in decimal.
Say you had 26 instead of 8.
7 in binary is 00000111 26 in binary is 00011010 -------- 00000010, which is 2 in decimal.
Bitwise operations are used to extract and process fields packed into numbers.
For example, suppose you had 3 fields packed into a single number, two of 4 bits (0..15), one and 3 bits (0..7).
ikegami
source share