getbit(
getbit(
NUMBER
,
BIT
)

The getbit( function returns the value of a bit within a number.

Parameters

This function has two parameters:

number – an integer value.

bit – the bit number to test, may be from 1 to 64.

Description

This function returns a true or false value by testing a bit within a number. The bit number may be from 1 to 64. If the bit is set, the returned value will be true (-1), if it is not set, the returned value will be false (0).

    getbit(5,1) ☞ -1 (true)
    getbit(5,2) ☞ 0 (false)
    getbit(5,3) ☞ -1 (true)
    getbit(5,4) ☞ 0 (false)

Note: This function is equivalent to:

    (bit(bitnum) and thenum) <> 0

See Also

- bit( -- converts a bit number (1 to 64) into a number (1, 2, 4, 8, 16, etc.)
- onescomplement( -- returns the one's complement of a 64 bit number (all bits are reversed)
- setbit( -- sets or clears one bit within a number, without disturbing any of the other bits.

History

Version | Status | Notes
10.0 | Updated | Carried over from Panorama 6.0, but now supports up to 64 bits (instead of 32).