Caché MultiValue Basic Reference
BITRESET


Sets the specified bit in a bitstring to 0.
Synopsis
BITRESET(bitstring,bitno)
The
BITRESET function defines a bit string using
bitstring and resets to 0 one bit of that bit string at the location specified by
bitno. Both values are specified as positive integers. If the bit specified by
bitno has a value of 1,
BITRESET sets it to 0. If the bit specified by
bitno already has a value of 0,
BITRESET leaves it unchanged.
Both
bitstring and
bitno can be expressed as either numbers or as strings. These numbers are converted to canonical form, with leading plus signs and leading and trailing zeros omitted. If either argument evaluates to the null string or a nonnumeric string it is assumed to have a value of 0. A string is parsed as a number until a nonnumeric character is encountered. Thus “7dwarves” is parsed as 7.
The
BITRESET function sets a specified bit to 0. The
BITSET function sets a specified bit to 1. The
BITNOT function sets a specified bit to its opposite value.
The following example specifies a
bitstring of 65 (binary 1000001), and
bitno resets bit position 0 to the bit value 0. This results in the binary string 1000000, the integer value of which is 64:
PRINT BITRESET(65,0); ! Returns 64
The following example specifies a
bitstring of 64 (binary 1000000), and
bitno resets bit position 6 to the bit value 0. This results in the binary string 0000000, the integer value of which is 0:
PRINT BITRESET(64,6); ! Returns 0
The following example specifies a
bitstring of 64 (binary 1000000), and
bitno specifies resetting bit position 0 to the bit value 0. But because bit position 0 already has a bit value of 0, the binary string 1000000 (integer value 64) is returned unchanged:
PRINT BITRESET(64,0); ! Returns 64
The following example specifies a
bitstring of 8 (binary 1000), and
bitno specifies resetting bit position 4 to the bit value 0. The
bitstring has an implicit bit position of 4, which already has a value of 0. Thus the original binary string 1000 (integer value 8) is returned unchanged:
PRINT BITRESET(8,4); ! Returns 8
The following example specifies a
bitstring of 0 (binary 0), and
bitno sets bit position 0 to the bit value 0. This results in the binary string 0, the integer value of which is 0:
PRINT BITRESET(0,0); ! Returns 0