This division operates on integer arguments, and delivers an integer result rounded down towards negative infinity (floored). The corresponding remainder is computed by the mod operation, such that the following equivalence always holds:
X =:= (X mod Y) + (X div Y) * Y.
The relationship with floating-point division is:
X div Y =:= integer(floor(X/Y)).
This predicate can be used as a function in arithmetic expressions. In coroutining mode, if Number1 or Number2 are uninstantiated, the call to (div)/3 is delayed until these variables are instantiated.
Success:
X is 10 div 3. % gives X = 3
X is -10 div 3. % gives X = -4
X is 10 div -3. % gives X = -4
X is -10 div -3. % gives X = 3
Error:
X is 2 div 0. % arithmetic exception