Navigation: Language Reference > 13 - Built-in Functions >====== BXOR (return bitwise exclusive OR) ====== | |
BXOR(value,mask)
BXOR | Performs bitwise exclusive OR operation. |
value | A numeric constant, variable, or expression for the bit value to be compared to the bit mask. The value is converted to a LONG data type prior to the operation, if necessary. |
mask | A numeric constant, variable, or expression for the bit mask. The mask is converted to a LONG data type prior to the operation, if necessary. |
The BXOR procedure compares the value to the mask, performing a Boolean XOR operation on each bit. The return value is a LONG integer with a one (1) in the bit positions where either the value or the mask contain a one (1), but not both. Zeroes are returned in all bit positions where the bits in the value and mask are alike.
BXOR is usually used to toggle on (1) or off (0) an individual bit, or multiple bits, within a variable.
Return Data Type: | LONG |
Example:
!BXOR(0110b,0010b) returns 0100b !0110b = 6, 0100b = 4, 0010b = 2
RateType BYTE !Type of rate
Female EQUATE(0001b) !Female mask
Male EQUATE(0010b) !Male mask
Over25 EQUATE(0100b) !Over age 25 mask
Over65 EQUATE(1100b) !Over age 65 mask
CODE
RateType = BXOR(RateType,Over65) !Toggle over 65 bits
See Also: