|
|
HP C/HP-UX Reference Manual: Workstations and Servers > Chapter 5 Expressions Multiplicative Operators |
|
The multiplicative operators perform multiplication (*), division (/), or remainder (%).
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%b==a- ((a/b)*b). The second operand (/ or %) must not be 0. Table 5-2 “Results for Inexact a/b” describes the result of a/b for positive and negative integer operands, when the result is inexact. Table 5-2 Results for Inexact a/b
For example, -5/2==-2. The true quotient is -2.5; the smallest integer greater than -2.5 is -2. Table 5-3 “Results for Non-zero ab” describes the sign of the result of a%b for positive and negative operands, when the result is not zero.
For example:
|
|