Multiplicative Operators

From RAD Studio
Jump to: navigation, search

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:

  1. * (multiplication)
  2. / (division)
  3. % (modulus or remainder)

The usual arithmetic conversions are made on the operands.

  1. (op1 * op2) Product of the two operands
  2. (op1 / op2) Quotient of (op1 divided by op2)
  3. (op1 % op2) Remainder of (op1 divided by op2)

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:

  1. If op1 and op2 have the same sign, op1 / op2 is the largest integer less than the true quotient, and op1 % op2 has the sign of op1.
  2. If op1 and op2 have opposite signs, op1 / op2 is the smallest integer greater than the true quotient, and op1 % op2 has the sign of op1.

Note: Rounding is always toward zero.

The * is context sensitive and can be used as the pointer reference operator.