BitwiseClearBit

Description

Allows you to clear the bit from a specified position in a binary number.

Syntax

BitwiseClearBit ( val, bit_Position)

Argument

Description

val

Unsigned long for the binary number with a bit that you want to change from 1 to 0

bit_Position

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

Returns

UnsignedLong. Returns the result for a binary number when a bit at the position specified by bit_Position is turned off. If one of its arguments is null, BitwiseClearBit 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 the variable testValue with its third bit cleared:

UnsignedLong ll_result

ll_result = BitwiseClearBit(testValue, 3)

In this example, if testValue is 12, it has bits in the third and fourth positions. The call to BitwiseClearBit turns off the bit in the third position and returns a value of 8. If testValue is 10, the bit in the third position is already turned off, so the value returned is 10.

See also