util.Integer.testBit
Returns TRUE, if in the INTEGER
value, the bit at the designed position is set.
Syntax
util.Integer.testBit(
i INTEGER
n INTEGER
)
RETURNS BOOLEAN
- i is an integer value to check.
- n is the bit position (LSB is at position zero).
Usage
The util.Integer.clearBit() method returns TRUE if the passed
integer value has the bit set to 1 at the specified position.
Note: The position of the least significant bit (LSB) is the position zero:
- In
00000001(integer 1), the bit set to 1 is at position 0. - In
00100010(integer 34), the bits set to 1 are at position 1 and 5.
Note: Bitwise methods provided by the
util.Integer class are
based on the INTEGER type. Consider the following facts when using these methods: - The
INTEGERtype is a four-byte signed integer: If the bit at position 31 is set to 1, the correspondingINTEGERvalue will be negative. Thus,util.Integer.not(0)produces theINTEGERvalue-1(11111111 11111111 11111111 11111111). - The
NULLvalue for theINTEGERtype is represented internally with the value0x80000000(10000000 00000000 00000000 00000000). WhenNULLis used with theutil.Integerbitwise methods, it will be interpreted as0x80000000instead of a null value. However, if the result of the bitwise operation produces the value0x80000000, it will be interpreted asNULLwhen used in an expression.
Example
IMPORT util
MAIN
DISPLAY util.Integer.testBit( 3, 1 ) -- displays 1 (TRUE)
END MAIN