Bitwise operators
Although rarely required in business contexts, BI# supports the full
range of bitwise operators. Bitwise operators work on the bit level of
int
values and combine two bits
according to these rules:
a | B | a & b | a | b | a ^ b | !a |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 1 |
1 | 0 | 0 | 1 | 1 | 0 |
0 | 1 | 0 | 1 | 1 | 1 |
1 | 1 | 1 | 1 | 0 | 0 |
These are examples of how to use bitwise operators in BI#:
int a = 7; // b00000111
int b = 10; // b00001010
int c = a & b; // b00000010 == 2
int d = a | b; // b00001111 == 15
int e = a ^ b; // b00001101 == 13
int f = !a; // b11111000