a %| b, a %^ b, a %& b and %! a, where a and b are REAL or structures with REAL components with integer elements >= 0 and <= 4294967295 = 2^32-1 nbits(x) |

There are 4 operators for working with integers considered as the sets of 32 bits specified by their binary representations. Bit Operation Precedence Meaning a %| b 1 Bitwise Or (OR) a %^ b 2 Bitwise Exclusive Or (XOR) a %& b 3 Bitwise And (AND) %!a 4 Bitwise Complement (COMPL) When an operand x is not an integer or x < 0 or x > 4294967295 = 2^32-1, the result of any of these operators is MISSING. For '%&', a bit of the result is 1 if and only if the corresponding bits in the operands are both 1. Example: 25 %& 19 is 17 because 11001b AND 10011b is 10001b For '%|', a bit of the result is 1 if and only if at least 1 of the corresponding bits in the operands is 1. Example: 25 %| 19 is 27 because 11001b OR 10011b is 11011b For '%^', a bit of the result is 1 if and only if exactly 1 of the corresponding bits in the operands are 1, that is, if the corresponding bits differ. Example: 25 %^ 19 is 10 because 11001b XOR 10011b is 01010b Operator '%!' operates on the immediately following variable considered as a collection of 32 bits, changing 1's to 0's and 0's to 1's. Examples: %! 25 is 4294967270 since COMPL(0000000000000000000000000011001b) is 11111111111111111111111111100110b %! 0 is 4294967295 since COMPL(0000000000000000000000000000000b) is 11111111111111111111111111111111b When an operand is LOGICAL, it is treated as having value 0 (F) or 1 (T). The result is always REAL. When any operand is MISSING, so is the result. Bit operators were introduced to be useful with the output of modelinfo(bitmodel:T). For example, 2^(i-1) %& modelinfo(bitmodel:T)[j] is non-zero if and only if the j-th term of the model contains the i-th factor or variate (assuming i <= 32). The operators were listed above in increasing order of precedence. Moreover, they have lower precedence that all arithmetic, comparison, or logical operators which means they are evaluated after all such operators. Examples: Expression Interpretation Value 17 %| 29 %^ 91 %& 11 17 %| (29 %^ (91 %& 11)) 23 %!21 %| 97 %& %! 33 (%!21) %| (97 %& (%!33)) 4294967274 1 %& 3 + 4 1 %& (3+4) 1 3 %^ 5 != 6 3 %^ (5 != 6) 2 1 %| 2 == 3 1 %| (2 == 3) 1 %!0 == 4294967295 %!(0 == 4294967295) 4294967295 To understand the last three examples, note that 5 != 6 is True and is interpreted as 1, and that 2 == 3 and 0 == 4294967295 are both False and are interpreted as 0. See topics 'arithmetic' and 'logic'. See topic 'arithmetic' for a description of the "shape" of the result when operands are not scalars. See also modelinfo(), nbits().

Gary Oehlert 2003-01-15