Init
This commit is contained in:
63
cppdraft/expr/shift.md
Normal file
63
cppdraft/expr/shift.md
Normal file
@@ -0,0 +1,63 @@
|
||||
[expr.shift]
|
||||
|
||||
# 7 Expressions [[expr]](./#expr)
|
||||
|
||||
## 7.6 Compound expressions [[expr.compound]](expr.compound#expr.shift)
|
||||
|
||||
### 7.6.7 Shift operators [expr.shift]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7230)
|
||||
|
||||
The shift operators << and >> group left-to-right[.](#1.sentence-1)
|
||||
|
||||
[shift-expression:](#nt:shift-expression "7.6.7 Shift operators [expr.shift]")
|
||||
[*additive-expression*](expr.add#nt:additive-expression "7.6.6 Additive operators [expr.add]")
|
||||
[*shift-expression*](#nt:shift-expression "7.6.7 Shift operators [expr.shift]") << [*additive-expression*](expr.add#nt:additive-expression "7.6.6 Additive operators [expr.add]")
|
||||
[*shift-expression*](#nt:shift-expression "7.6.7 Shift operators [expr.shift]") >> [*additive-expression*](expr.add#nt:additive-expression "7.6.6 Additive operators [expr.add]")
|
||||
|
||||
The operands shall be prvalues of integral or unscoped enumeration type and integral
|
||||
promotions are performed[.](#1.sentence-2)
|
||||
|
||||
The type of the result is that of the promoted
|
||||
left operand[.](#1.sentence-3)
|
||||
|
||||
The behavior is undefined if the right operand is negative, or greater
|
||||
than or equal to the width of the promoted left operand[.](#1.sentence-4)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7258)
|
||||
|
||||
The value of E1 << E2 is the unique value congruent toE1Ã2E2 modulo 2N,
|
||||
where N is the width of the type of the result[.](#2.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
E1 is left-shifted E2 bit positions;
|
||||
vacated bits are zero-filled[.](#2.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7267)
|
||||
|
||||
The value of E1 >> E2 is E1/2E2,
|
||||
rounded towards negative infinity[.](#3.sentence-1)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
E1 is right-shifted E2 bit positions[.](#3.sentence-2)
|
||||
|
||||
Right-shift on signed integral types is an arithmetic right shift,
|
||||
which performs sign-extension[.](#3.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7276)
|
||||
|
||||
The expression E1 is sequenced before the expression E2[.](#4.sentence-1)
|
||||
Reference in New Issue
Block a user