The Oberon language report defines DIV and MOD as follows:
The following are examples of the new conforming behaviour:The operators DIV and MOD apply to integer operands only. Let q = x DIV y, and r = x MOD y.
Then quotient q and remainder r are defined by the equation
Code: Select all
x = q*y + r 0 <= r < y
Constants:
Code: Select all
q := 10 DIV -3; (* Compile Error: divisor must be > 0 *)
r := 10 MOD -3; (* Compile Error: modulus must be > 0 *)
q := (-10) DIV 3; (* q = -4 *)
r := (-10) MOD 3; (* r = 2 *)
Code: Select all
x := 10;
y := -3;
q := x DIV y; (* Runtime Error 7 *)
r := x MOD y; (* Runtime Error 7 *)
Code: Select all
q := -10 DIV 3; (* q = -3 *)
q := -(10 DIV 3); (* q = -3 *)
Code: Select all
r := -10 MOD 3; (* r = -1 *)
r := -(10 MOD 3); (* r = -1 *)