bitGet()
Purpose
Get the value of a bit in a binary number
Description
Find out if the value of the specified bit in a binary number is 0 or 1
Syntax
result = bitGet( number, bit )
Arguments
number Number value
bit Bit to get the value of (0-31). Bit 31 is the sign bit.
result Resulting bit value (0 or 1)
Example
number = random( 100000 ) + 1
bit0 = bitGet( number, 0 )
if bit0 > 0 then
print( number, " is an odd number" )
else
print( number, " is an even number" )
endIf
update()
sleep( 3 )
Associated Commands
bitCount(), bitSet(), bitFieldExtract(), bitFieldInsert(), leadingZeroes(), trailingZeroes()