tmp/tmp4ppcyq2m/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Usual arithmetic conversions <a id="expr.arith.conv">[[expr.arith.conv]]</a>
|
| 2 |
+
|
| 3 |
+
Many binary operators that expect operands of arithmetic or enumeration
|
| 4 |
+
type cause conversions and yield result types in a similar way. The
|
| 5 |
+
purpose is to yield a common type, which is also the type of the result.
|
| 6 |
+
This pattern is called the *usual arithmetic conversions*, which are
|
| 7 |
+
defined as follows:
|
| 8 |
+
|
| 9 |
+
- If either operand is of scoped enumeration type [[dcl.enum]], no
|
| 10 |
+
conversions are performed; if the other operand does not have the same
|
| 11 |
+
type, the expression is ill-formed.
|
| 12 |
+
- If either operand is of type `long double`, the other shall be
|
| 13 |
+
converted to `long double`.
|
| 14 |
+
- Otherwise, if either operand is `double`, the other shall be converted
|
| 15 |
+
to `double`.
|
| 16 |
+
- Otherwise, if either operand is `float`, the other shall be converted
|
| 17 |
+
to `float`.
|
| 18 |
+
- Otherwise, the integral promotions [[conv.prom]] shall be performed on
|
| 19 |
+
both operands.[^9] Then the following rules shall be applied to the
|
| 20 |
+
promoted operands:
|
| 21 |
+
- If both operands have the same type, no further conversion is
|
| 22 |
+
needed.
|
| 23 |
+
- Otherwise, if both operands have signed integer types or both have
|
| 24 |
+
unsigned integer types, the operand with the type of lesser integer
|
| 25 |
+
conversion rank shall be converted to the type of the operand with
|
| 26 |
+
greater rank.
|
| 27 |
+
- Otherwise, if the operand that has unsigned integer type has rank
|
| 28 |
+
greater than or equal to the rank of the type of the other operand,
|
| 29 |
+
the operand with signed integer type shall be converted to the type
|
| 30 |
+
of the operand with unsigned integer type.
|
| 31 |
+
- Otherwise, if the type of the operand with signed integer type can
|
| 32 |
+
represent all of the values of the type of the operand with unsigned
|
| 33 |
+
integer type, the operand with unsigned integer type shall be
|
| 34 |
+
converted to the type of the operand with signed integer type.
|
| 35 |
+
- Otherwise, both operands shall be converted to the unsigned integer
|
| 36 |
+
type corresponding to the type of the operand with signed integer
|
| 37 |
+
type.
|
| 38 |
+
|
| 39 |
+
If one operand is of enumeration type and the other operand is of a
|
| 40 |
+
different enumeration type or a floating-point type, this behavior is
|
| 41 |
+
deprecated [[depr.arith.conv.enum]].
|
| 42 |
+
|