Scripts > Class elements and c++ instructions > Interpreted C++ instructions > Operators > Bitwise operators
Remark
Use the bitwise operators to modify the individual bits rather than the number.
Operator

What it does

&

bitwise AND; compares two bits and generates a 1 result if both bits are 1, otherwise it returns 0.



bitwise inclusive OR; compares two bits and generates a 1 result if either or both bits are 1, otherwise it returns 0.

^

bitwise exclusive OR; compares two bits and generates a 1 result if the bits are complementary, otherwise it returns 0.

~

bitwise complement; inverts each bit. ~ is used to create destructors.

>>

bitwise shift right; moves the bits to the right, discards the far right bit and assigns the left most bit to 0.

<<

bitwise shift left; moves the bits to the left, it discards the far left bit and assigns the right most bit to 0.

Both operands in a bitwise expression must be of an integral type.
Bit value

Bit value

Result of

Result of

Result of

E1

E2

E1 & E2

E1 ^ E2

E1  E2

0

0

0

0

0

1

0

0

1

1

0

1

0

1

1

1

1

1

0

1

Note: &, >>, << are context sensitive:
& can also be the reference operator.
>> can also be the input operator in I/O expressions.
<< can also be the output operator in I/O expressions.
