Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The \ operator calculates an integral quotient of its two operands, rounding the quotient towards zero.
The Mod operator calculates the remainder formed when dividing its two operands.
-
integer-division-operator-expression = expression "\" expression modulo-operator-expression = expression "mod" expression
Static semantics:
§ A \ operator expression or Mod operator expression has the standard static semantics for binary arithmetic operators (section 5.6.9.3) with the following exceptions when determining the operator’s declared type:
Left Operand Declared Type |
Right Operand Declared Type |
Operator Declared Type |
---|---|---|
Any floating-point or fixed-point numeric type, String, String * length or Date |
Any numeric type, String, String * length or Date |
Long |
Any numeric type, String, String * length or Date |
Any floating-point or fixed-point numeric type, String, String * length or Date |
Long |
Runtime semantics:
§ A \ operator expression or Mod operator expression has the standard runtime semantics for binary arithmetic operators (section 5.6.9.3) with the following exceptions when determining the operator’s effective value type:
Left Operand Value Type |
Right Operand Value Type |
Effective Value Type |
---|---|---|
Byte |
Empty |
Integer |
Empty |
Byte |
Integer |
Boolean or Integer |
Single, Double, String, Currency, Date or Decimal |
Integer |
Any floating-point or fixed-point numeric type, String, or Date |
Any numeric type except LongLong, String, Date or Empty |
Long |
Any numeric type except LongLong, String, Date or Empty |
Any floating-point or fixed-point numeric type, String, or Date |
Long |
LongLong |
Any numeric type, String, Date or Empty |
LongLong |
Any numeric type, String, Date or Empty |
LongLong |
LongLong |
§ The semantics of the \ operator depend on the operator’s effective value type:
Effective Value Type |
Runtime Semantics |
---|---|
Byte, Integer, Long or LongLong |
The quotient is the left operand divided by the right operand.
If the quotient is an integer, the result is the quotient.
Otherwise, if the quotient is not an integer, the result is the integer nearest to the quotient that is closer to zero than the quotient.
If this results in dividing by 0, runtime error 11 (Division by zero) is raised. |
Null |
The result is the value Null. |
§ The semantics of the Mod operator depend on the operator’s effective value type:
Effective Value Type |
Runtime Semantics |
---|---|
Byte, Integer, Long or LongLong |
The quotient is the left operand divided by the right operand.
If the quotient is an integer, the result is 0.
Otherwise, if the quotient is not an integer, the truncated quotient is the integer nearest to the quotient that is closer to zero than the quotient. The result is the absolute value of the difference between the left operand and the product of the truncated quotient and the right operand.
If this results in dividing by 0, runtime error 11 (Division by zero) is raised. |
Null |
The result is the value Null. |