C++ Syntax: shift: << >>
Description
The shift operators bitwise shift the value on their left by the number
of bits on their right:-
- << shifts left and adds zeros at the right end.
- >> shifts right and adds either 0s, if value is an unsigned type, or
extends the top bit (to preserve the sign) if its a signed type.
So
2 << 4
is 32 and
-8 >> 3
is -1.
See operator
precedence
Other Uses for << >>
<< and >> are reused
(i.e. overloaded)
as the
input/output
operators.
Usage Notes
None.
Go Back to the
The C++ Crib Top Page
If you have any comments about this page please send them to
Nick West