These operators deal with the bits patterns that comprise values in C (and in every other programming language). All well-known, standard bit operations are supported.
| OP | Name | Example | Description |
|---|---|---|---|
~
|
Complement | ~x
|
Toggle all bits 1↔0 |
&
|
Bitwise AND | x&y
|
Bitwise AND of x, y
|
|
|
Bitwise OR | x|y
|
Bitwise OR of x, y
|
^
|
Bitwise XOR | x^y
|
Bitwise XOR of x, y
|
<<
|
Left shift | x<<y
|
Shift x y bits to the left
|
>>
|
Right shift | x>>y
|
Shift x y bits to the right
|
Bitwise Complement
This operator changes all of its operand's bits from 0 to 1 and vice versa.
Bitwise AND, OR and XOR
These apply the respective Boolean operators to all bits in their operands. They work like their BASIC counterparts.
Left and Right Shifts
These operators move (shift) the bits of their first operand N places to the left or right, where N is the second operand. Bits ‘pushed off’ are lost, and ‘empty places’ are filled with 0 bits. So, shifting 00010111 two places to the right, we get 00000101. These are bitwise shift operators, which means that they deal with all of their operands' bits, regardless of whether the operands are signed or not. Shifting a number one place to the left doubles it; shifting it to the right halves it. This is much faster than integer multiplication or division, and so it is preferred (although most compilers, the Oric one included, take advantage of this fact to speed up programs).




Add new comment