@@ -1719,7 +1719,17 @@ The :t:`evaluation` of a :t:`shift left expression` proceeds as follows:
1719
1719
The :t: `right operand ` is evaluated.
1720
1720
1721
1721
#. :dp: `fls_f0p70y92k14f `
1722
- ``core::ops::Shl::shl(left_operand, right_operand) `` is invoked.
1722
+ If the types of both :t: `[operand]s ` are :t: `[integer type]s `, then the
1723
+ :t: `shift left expression ` evaluates to the value of the left :t: `operand `
1724
+ whose bits are shifted left by the number of positions the right :t: `operand `
1725
+ evaluates to. Vacated bits are filled with zeros. ``lhs << rhs `` evaluates
1726
+ to :math: `\mathrm {lhs} \times 2 ^ \mathrm {rhs}`, casted to the type of the left
1727
+ :t: `operand `. If the value of the right :t: `operand ` is negative or greater
1728
+ than or equal to the width of the left operand, then the operation results in
1729
+ an :t: `arithmetic overflow `.
1730
+
1731
+ #. :dp: `fls_8QGbl2SBU3R0 `
1732
+ Otherwise, ``core::ops::Shl::shl(left_operand, right_operand) `` is invoked.
1723
1733
1724
1734
:dp: `fls_303r0u6ug215 `
1725
1735
The :t: `evaluation ` of a :t: `shift right expression ` proceeds as follows:
@@ -1730,8 +1740,20 @@ The :t:`evaluation` of a :t:`shift right expression` proceeds as follows:
1730
1740
#. :dp: `fls_gurl2ve58drz `
1731
1741
The :t: `right operand ` is evaluated.
1732
1742
1743
+ #. :dp: `fls_r02OGonXp93A `
1744
+ If the types of both :t: `[operand]s ` are :t: `[integer type]s `, then the
1745
+ :t: `shift right expression ` evaluates to the value of the left :t: `operand `
1746
+ whose bits are shifted right by the number of positions the right
1747
+ :t: `operand ` evaluates to. If the type of the left :t: `operand ` is any
1748
+ :t: `signed integer type ` and is negative, then vacated bits are filled
1749
+ with ones. Otherwise, vacated bits are filled with zeros. ``lhs >> rhs ``
1750
+ evaluates to :math: `\mathrm {lhs} / 2 ^ \mathrm {rhs}`, casted to the type of
1751
+ the left :t: `operand `. If the value of the right :t: `operand ` is negative,
1752
+ greater than or equal to the width of the left operand, then the operation
1753
+ results in an :t: `arithmetic overflow `.
1754
+
1733
1755
#. :dp: `fls_xkyj83mcb9d5 `
1734
- ``core::ops::Shr::shr(left_operand, right_operand) `` is invoked.
1756
+ Otherwise, ``core::ops::Shr::shr(left_operand, right_operand) `` is invoked.
1735
1757
1736
1758
.. rubric :: Examples
1737
1759
@@ -5099,9 +5121,11 @@ Arithmetic Overflow
5099
5121
-------------------
5100
5122
5101
5123
:dp: `fls_oFIRXBPXu6Zv `
5102
- An :t: `arithmetic overflow ` occurs when an :t: `arithmetic expression ` or a
5103
- :t: `negation expression ` computes a :t: `value ` of a :t: `scalar type ` that lies
5104
- outside of the range of valid :t: `[value]s ` for the :t: `scalar type `.
5124
+ An :t: `arithmetic overflow ` occurs when an :t: `operator expression ` computes a
5125
+ :t: `value ` of a :t: `scalar type ` that lies outside of the range of valid
5126
+ :t: `[value]s ` for the :t: `scalar type ` or when one or more :t: `operand ` of an
5127
+ :t: `operator expression ` lies outside of the range of valid :t: `[value]s ` for
5128
+ the operation.
5105
5129
5106
5130
.. rubric :: Dynamic Semantics
5107
5131
0 commit comments