BitClear

Use this function to return the result after clearing the specified bit in a value.

Syntax

BitClear(value1, bitpos)

The parameters specify the numeric value and the bit position on which the operation is performed. The specified bit is set to a zero (0) in the value provided. If the bit was not on, the value is unchanged. Specifying a negative or zero bit position does not result in any change to the value.

Note that integer values have 32 bits. When looking at the value in binary form, bit 1 is on the left and bit 32 is on the right.

Bit 32 -->0000 0000 0000 0000 0000 0000 0000 0000<-- Bit 1

Example

Here is an example:

y = 6 (6 is 0110 in binary)

z = BitClear(x,1)

z = 6 (6 is 0110 in binary) (bit 1 was already zero)

 

y = 6 (6 is 0110 in binary)

z = BitClear(x,2)

z = 4 (4 is 0100 in binary)

See also