7
Expressions
[expr]
7.6
Compound expressions
[expr.compound]
7.6.7
Shift operators
[expr.shift]
1
#
The shift operators
<
<
and
>
>
group left-to-right
.
shift-expression
:
additive-expression
shift-expression
<
<
additive-expression
shift-expression
>
>
additive-expression
The operands shall be of integral or unscoped enumeration type and integral promotions are performed
.
The type of the result is that of the promoted left operand
.
The behavior is undefined if the right operand is negative, or greater than or equal to the width of the promoted left operand
.
2
#
The value of
E1
<
<
E2
is the unique value congruent to
E1
×
2
E2
modulo
2
N
, where
N
is the width of the type of the result
.
[
Note
:
E1
is left-shifted
E2
bit positions; vacated bits are zero-filled
.
—
end note
]
3
#
The value of
E1
>
>
E2
is
E1
/
2
E2
, rounded down
.
[
Note
:
E1
is right-shifted
E2
bit positions
.
Right-shift on signed integral types is an arithmetic right shift, which performs sign-extension
.
—
end note
]
4
#
The expression
E1
is sequenced before the expression
E2
.