From Jason Turner

[expr.shift]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4p2ai_fd/{from.md → to.md} +13 -17
tmp/tmp4p2ai_fd/{from.md → to.md} RENAMED
@@ -1,6 +1,6 @@
1
- ## Shift operators <a id="expr.shift">[[expr.shift]]</a>
2
 
3
  The shift operators `<<` and `>>` group left-to-right.
4
 
5
  ``` bnf
6
  shift-expression:
@@ -10,26 +10,22 @@ shift-expression:
10
  ```
11
 
12
  The operands shall be of integral or unscoped enumeration type and
13
  integral promotions are performed. The type of the result is that of the
14
  promoted left operand. The behavior is undefined if the right operand is
15
- negative, or greater than or equal to the length in bits of the promoted
16
- left operand.
17
 
18
- The value of `E1 << E2` is `E1` left-shifted `E2` bit positions; vacated
19
- bits are zero-filled. If `E1` has an unsigned type, the value of the
20
- result is $\mathrm{E1}\times2^\mathrm{E2}$, reduced modulo one more than
21
- the maximum value representable in the result type. Otherwise, if `E1`
22
- has a signed type and non-negative value, and
23
- $\mathrm{E1}\times2^\mathrm{E2}$ is representable in the corresponding
24
- unsigned type of the result type, then that value, converted to the
25
- result type, is the resulting value; otherwise, the behavior is
26
- undefined.
27
 
28
- The value of `E1 >> E2` is `E1` right-shifted `E2` bit positions. If
29
- `E1` has an unsigned type or if `E1` has a signed type and a
30
- non-negative value, the value of the result is the integral part of the
31
- quotient of $\mathrm{E1}/2^\mathrm{E2}$. If `E1` has a signed type and a
32
- negative value, the resulting value is *implementation-defined*.
 
 
 
33
 
34
  The expression `E1` is sequenced before the expression `E2`.
35
 
 
1
+ ### Shift operators <a id="expr.shift">[[expr.shift]]</a>
2
 
3
  The shift operators `<<` and `>>` group left-to-right.
4
 
5
  ``` bnf
6
  shift-expression:
 
10
  ```
11
 
12
  The operands shall be of integral or unscoped enumeration type and
13
  integral promotions are performed. The type of the result is that of the
14
  promoted left operand. The behavior is undefined if the right operand is
15
+ negative, or greater than or equal to the width of the promoted left
16
+ operand.
17
 
18
+ The value of `E1 << E2` is the unique value congruent to `E1` × 2^`E2`
19
+ modulo 2ᴺ, where N is the width of the type of the result.
 
 
 
 
 
 
 
20
 
21
+ [*Note 1*: `E1` is left-shifted `E2` bit positions; vacated bits are
22
+ zero-filled. *end note*]
23
+
24
+ The value of `E1 >> E2` is `E1` / 2^`E2`, rounded down.
25
+
26
+ [*Note 2*: `E1` is right-shifted `E2` bit positions. Right-shift on
27
+ signed integral types is an arithmetic right shift, which performs
28
+ sign-extension. — *end note*]
29
 
30
  The expression `E1` is sequenced before the expression `E2`.
31