Bit

bit(value, bitno)

Returns the status of the given bit in an integer value

Description

bit(19, 1)

Returns the value of bit 1 (the second bit) in the value 19.

19 (decimal) written as binary is 10011. Thus, bit 4, 1 and 0 are set. Bit 0 is the first from the right.

Parameters

value The input value (64 bit integer)
bitno The bit number to return

Return value

Returns 1 if the bit is set. 0 if the bit is not set.

Example usage

bit(211, 5) // returns 0
bit(211, 4) // returns 1

[Available in firmware 201008 and newer]