The bitwise operators are a Transact-SQL extension for use with the datatype integer. These operators convert each integer operand into its binary representation and then evaluate the operands column by column. A value of 1 corresponds to true; a value of 0 corresponds to false.
Table 1-4 and Table 1-5 summarize the results for operands of 0 and 1. If either operand is NULL, the bitwise operator returns NULL:
& (and) |
1 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
| (or) |
1 |
0 |
1 |
1 |
1 |
0 |
1 |
0 |
^ (exclusive or) |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
~ (not) |
||
1 |
FALSE |
|
0 |
0 |
The following examples use two tinyint arguments: A = 170 (10101010 in binary form) and B = 75 (01001011 in binary form).
Copyright © 2005. Sybase Inc. All rights reserved. |