Arithmetic operators | Previous Top Next

Arithmetic operators, which take real or integer operands, include +, –, *, /, div, and mod.
Operator Operation Operand types Result type Example
+ addition integer, real integer, real X + Y
– subtraction integer, real integer, real Result - 1
* multiplication integer, real integer, real P * InterestRate
/ real division integer, real real X / 2
div integer division integer integer Total div UnitSize
mod remainder integer integer Y mod 6
Operator Operation Operand type Result type Example
+ (unary) sign identity integer, real integer, real +7
– (unary) sign negation integer, real integer, real -X
The following rules apply to arithmetic operators.
The value of x/y is of type Extended, regardless of the types of x and y. For other arithmetic operators, the result is of type Extended whenever at least one operand is a real; otherwise, the result is of type Int64 when at least one operand is of type Int64; otherwise, the result is of type Integer. If an operand's type is a subrange of an integer type, it is treated as if it were of the integer type.
The value of x div y is the value of x/y rounded in the direction of zero to the nearest integer.
The mod operator returns the remainder obtained by dividing its operands. In other words, x mod y = x – (x div y) * y.
A runtime error occurs when y is zero in an expression of the form x/y, x div y, or x mod y.