setBit()
Sets a bit within a bit32/bit64 variable.
Synopsis
int setBit(bit32 &aBitVar, int position, bool value);
int setBit(bit64 &aBitVar, int position, bool value);
Parameters
Parameter | Description |
---|---|
aBitVar | bit32/bit64 variable to be modified |
position | position of the bit |
value | value to be set |
Return value
In the event of an error -1, otherwise 0.
Errors
no/incorrect arguments
Description
Sets the bit at the position position in the range from 0 to 31 (32-Bit) or from 0 to 63 (64-Bit) to the value value(TRUE or FALSE). The least significant bit is the 0 position.
Only the number of arguments and whether it is a 32-Bit variable or a 64-Bit variable are checked here.
Example
main()
{
bit32 b;
setPattern(b, "1001");
setBit(b, 2, TRUE); // b is now 13 (1101)
}
Assignment
Availability
CTRL