BitwiseGetBit

Description

Allows you check whether a bit is turned on at a specified position of a binary number.

Syntax

BitwiseGetBit ( val, bit_Position)

Argument

Description

val

Unsigned long for the binary number with a bit that you want to check

bit_Position

Unsigned integer for the position, from 1 to 32, of the bit you want to check

Returns

Boolean. Returns true if the bit at the specified position is turned on and returns false if it is not. If one of its arguments is null, BitwiseGetBit returns null.

Usage

In PocketBuilder there are 32 bits in an unsigned long. If the value of bit_Position is 0, or greater than 32, PocketBuilder fires the runtime SystemError event because the value is out of range.

Examples

Example 1

This example determines whether the values of the bit at the third position is on or off:

boolean lb_result

lb_result = BitwiseGetBit(testValue, 3)

In this example, if testValue is 12, it has bits in the third and fourth positions, and the call to BitwiseGetBit returns true. If testValue is 10, it has bits at the second and fourth positions only, so BitwiseGetBit returns false.

See also