56 lines
2.7 KiB
Markdown
56 lines
2.7 KiB
Markdown
[expr.mul]
|
||
|
||
# 7 Expressions [[expr]](./#expr)
|
||
|
||
## 7.6 Compound expressions [[expr.compound]](expr.compound#expr.mul)
|
||
|
||
### 7.6.5 Multiplicative operators [expr.mul]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7059)
|
||
|
||
The multiplicative operators *, /, and % group
|
||
left-to-right[.](#1.sentence-1)
|
||
|
||
[multiplicative-expression:](#nt:multiplicative-expression "7.6.5 Multiplicative operators [expr.mul]")
|
||
[*pm-expression*](expr.mptr.oper#nt:pm-expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]")
|
||
[*multiplicative-expression*](#nt:multiplicative-expression "7.6.5 Multiplicative operators [expr.mul]") * [*pm-expression*](expr.mptr.oper#nt:pm-expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]")
|
||
[*multiplicative-expression*](#nt:multiplicative-expression "7.6.5 Multiplicative operators [expr.mul]") / [*pm-expression*](expr.mptr.oper#nt:pm-expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]")
|
||
[*multiplicative-expression*](#nt:multiplicative-expression "7.6.5 Multiplicative operators [expr.mul]") % [*pm-expression*](expr.mptr.oper#nt:pm-expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]")
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7079)
|
||
|
||
The operands of * and / shall have arithmetic or unscoped
|
||
enumeration type; the operands of % shall have integral or unscoped
|
||
enumeration type[.](#2.sentence-1)
|
||
|
||
The [usual arithmetic conversions](expr.arith.conv "7.4 Usual arithmetic conversions [expr.arith.conv]") are performed on the
|
||
operands and determine the type of the result[.](#2.sentence-2)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7085)
|
||
|
||
The binary * operator indicates multiplication[.](#3.sentence-1)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7088)
|
||
|
||
The binary / operator yields the quotient, and the binary% operator yields the remainder from the division of the first
|
||
expression by the second[.](#4.sentence-1)
|
||
|
||
If the second operand of / or % is zero, the behavior is
|
||
undefined[.](#4.sentence-2)
|
||
|
||
For integral operands, the / operator yields the algebraic quotient with
|
||
any fractional part discarded;[63](#footnote-63 "This is often called truncation towards zero.") 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[.](#4.sentence-3)
|
||
|
||
[63)](#footnote-63)[63)](#footnoteref-63)
|
||
|
||
This is often called truncation towards zero[.](#footnote-63.sentence-1)
|