Multiplicative Operators
Go Up to Binary Operators Index
Syntax
multiplicative-expression * cast-expression multiplicative-expression / cast-expression multiplicative-expression % cast-expression
Remarks
There are three multiplicative operators:
- * (multiplication)
- / (division)
- % (modulus or remainder)
The usual arithmetic conversions are made on the operands.
(op1 * op2)
Product of the two operands(op1 / op2)
Quotient of (op1
divided byop2
)(op1 % op2)
Remainder of (op1 divided byop2
)
For / and %, op2
must be nonzero. op2 = 0
results in an error. (You can't divide by zero.)
When op1
and op2
are integers and the quotient is not an integer:
- If
op1
andop2
have the same sign,op1 / op2
is the largest integer less than the true quotient, andop1 % op2
has the sign ofop1
. - If
op1
andop2
have opposite signs,op1 / op2
is the smallest integer greater than the true quotient, andop1 % op2
has the sign ofop1
.
Note: Rounding is always toward zero.
The * is context sensitive and can be used as the pointer reference operator.