Top  | Previous | Next

Logic / getBit

getBit(number, position)

This function returns the bit value (an integer, 0 or 1) in the number at position position, according to its binary representation. The least significant bit in a number is position 0.

 

getBit(0,0) 

...would return 0

 

getBit(1,0) 

...would return 1

 

getBit(8,3)

...would return 1

 

getBit(8,2) 

...would return 0