TESTON

The TESTON function tests a specified bit in a binary number to see if it is on.

Syntax:

TESTON ( single-binary-number-expression, single-integer-expression )

Meaning:
TESTON ( binary_number_to_test ,bit_to_test )
Returns:
"True" or "false"

The value of bit_to_test specifies the bit of binary_number_to_test to test for the value 1. If bit_to_test has the value 1, it refers to the leftmost bit of binary_number_to_test.

The function returns "true" if the specified bit is on; it has the value 1. It returns "false" if the specified bit is off; it has the value 0.

If bit_to_test is less than one or greater than the number of bits of binary_number_to_test, TESTON returns "false".

Examples

  • TESTON ( A , 16 )

    Assume A is the two-byte binary value of "1", which is all zeros except for bit 16. The binary representation of the value in A is 0001.

    This example returns "true".

  • TESTON ( A , 20 )

    Returns "false" because bit 20 does not exist in a two-byte value.