testBit

testBit(integer x, integer bit) → boolean set

Returns true if the bit at position bit of the number x is 1, and false otherwise. Position 0 is the least significant bit. The function also works on big integers.

testBit(8, 3)   // true  : 8 = 1000, bit 3 is 1
testBit(8, 0)   // false : bit 0 is 0
testBit(13, 2)  // true  : 13 = 1101, bit 2 is 1
Math.testBit(8, 3)  // true  : 8 = 1000, bit 3 is 1
Math.testBit(8, 0)  // false : bit 0 is 0
Math.testBit(13, 2) // true  : 13 = 1101, bit 2 is 1
Math.testBit(8, 3)  # True  : 8 = 1000, bit 3 is 1
Math.testBit(8, 0)  # False : bit 0 is 0
Math.testBit(13, 2) # True  : 13 = 1101, bit 2 is 1
Parameters
Return
Note