BitReset
 
Macro that clears a bit in an integer

Syntax

#define BitReset( value, bit_number ) ((value) And Not (Cast(TypeOf(Value), 1) Shl (bit_number)))

Usage

result = BitReset(value, bit_number)

Parameters

value
The integer value to clear a bit in. It is not modified.
bit_number
The zero-based number of the bit to clear; 0 is the least-significant bit.

Return Value

value with bit bit_number cleared.

Description

Macro returning value with the bit bit_number reset to 0.
foo = BitReset( bar, 5 ) does the same as foo = bar and not (1 shl 5).

Example

Print BitReset(5,0)
Print Hex(BitReset(&h8000000000000001,63))

will produce the output:

 4
1

Dialect Differences

  • Not available in the -lang qb dialect.

Differences from QB

  • New to FreeBASIC.

See also