Bit shift operator

Syntax

…int-expr… << …int-expr…

…int-expr… >> …int-expr…

Typing

int, int -> int

Description

Shift its first integer operand by the number of bits indicated by its second operand, to the left or to the right.

For right shifts, sign will be extended if the first operand is signed.

Examples

expression evaluates to
1029 >> 3 128
5 << 3 40
-4 >> 1 -2

See Also

Bitwise AND operator Bitwise OR operator Bitwise XOR operator