Files
cppdraft_translate/cppdraft/expr/mul.md
2025-10-25 03:02:53 +03:00

2.7 KiB

[expr.mul]

7 Expressions [expr]

7.6 Compound expressions [expr.compound]

7.6.5 Multiplicative operators [expr.mul]

1

#

The multiplicative operators *, /, and % group left-to-right.

multiplicative-expression:
pm-expression
multiplicative-expression * pm-expression
multiplicative-expression / pm-expression
multiplicative-expression % pm-expression

2

#

The operands of * and / shall have arithmetic or unscoped enumeration type; the operands of % shall have integral or unscoped enumeration type.

The usual arithmetic conversions are performed on the operands and determine the type of the result.

3

#

The binary * operator indicates multiplication.

4

#

The binary / operator yields the quotient, and the binary% operator yields the remainder from the division of the first expression by the second.

If the second operand of / or % is zero, the behavior is undefined.

For integral operands, the / operator yields the algebraic quotient with any fractional part discarded;63 if the quotient a/b is representable in the type of the result,(a/b)*b + a%b is equal to a; otherwise, the behavior of both a/b and a%b is undefined.

63)63)

This is often called truncation towards zero.