HP C/iX Reference Manual (31506-90011)
Chapter 5 75
Expressions
Bitwise Shift Operators
Bitwise Shift Operators
The bitwise shift operators shift the left operand left (\<\<) or right (\>\>) by the number
of bit positions specified by the right operand.
Syntax
shift-expression
:=
additive-expression
shift-expression
<<
additive-expression
shift-expression
>>
additive-expression
Description
Both operands must be of integral type. The integral promotions are performed on both
operands. The type of the result is the type of the promoted left operand.
The left shift operator << shifts the first operand to the left and zero fills the result on the
right. The right shift operator >> shifts the first operand to the right. If the type of the left
operand is an unsigned type, the >> operator zero fills the result on the left. If the type of
the left operand is a signed type, copies of the sign bit are shifted into the left bits of the
result (sometimes called sign extend).
Example
var1>>var2