HP C/iX Reference Manual (31506-90011)

72 Chapter5
Expressions
Multiplicative Operators
Multiplicative Operators
The multiplicative operators perform multiplication (*), division (/), or remainder (%).
Syntax
multiplicative-expression
:=
cast-expression
multiplicative-expression
*
cast-expression
multiplicative-expression
/
cast-expression
multiplicative-expression cast-expression
Description
Each of the operands in a multiplicative expression must have arithmetic type. Further,
the operands for the % operator must have integral type.
The usual arithmetic conversions are performed on the operands to select a resulting type.
The result is not an lvalue.
The result of the multiplication operator * is the arithmetic product of the operands.
The result of the division operator / is the quotient of the operands.
The result of the mod operator % is the remainder when the left argument is divided by the
right argument. By definition, a%ba-a/b)*b). The second operand (/ or %) must not be 0.
The following table describes the result of a/b for positive and negative integer operands,
when the result is inexact.
For example, -5/2 -2. The true quotient is -2.5; the smallest integer greater than -2.5 is
-2.
The following table describes the sign of the result of ab for positive and negative
Table 5-2. C Operator Precedence
b positive b negative
a
positive
Largest
integer less
than the
true
quotient.
Smallest
integer
greater than
the true
quotient.
a
negative
Smallest
integer
greater than
the true
quotient.
Largest
integer less
than the
true
quotient.