Arithmetic Comparisons

The arithmetic comparisons are more flexible than the lexical comparisons. They are defined for integers, floats and decimals. For decimals comparison across scales is supported. The same widening as already defined for the basic operations applies as well:

Examples:
1 < 2
1.0 < 2.0
0d1.00D < 2
1 =:= 0d1.00

We also provide evaluable functions min/2 and max/2. These functions are based on the aforementioned arithmetic comparison. The type of the return value depends on the order of the arguments of these evaluable functions:

min, max: integer x integer -> integer
min, max: float x float -> float
min, max: decimal x decimal -> decimal
epsilon: float

The constant epsilon allows querying the smallest float number that when added to one will still result in a float number different from one without any rounding.

The following built-in predicates are provided for arithmetic comparison. The built-ins arithmetically evaluate their arguments before performing their tests:

X =:= Y: [ISO 8.7.1]
Succeeds when X arithmetically equals Y, otherwise fails.
X =\= Y: [ISO 8.7.1]
Succeeds when X does not arithmetically equal Y, otherwise fails.
X < Y: [ISO 8.7.1]
Succeeds when X is arithmetically less than Y, otherwise fails.
X =< Y: [ISO 8.7.1]
Succeeds when X is arithmetically less or equal to Y, otherwise fails.
X > Y: [ISO 8.7.1]
Succeeds when X is arithmetically greater than Y, otherwise fails.
X >= Y: [ISO 8.7.1]
Succeeds when X is arithmetically greater or equal to Y, otherwise fails.

The following evaluable functions are provided for arithmetic comparison:

min(X, Y): [TC2 9.3.9]
If X and Y are both numbers then the function returns the minimum of X and Y.
max(X, Y): [TC2 9.3.8]
If X and Y are both numbers then the function returns the maximum of X and Y.
epsilon: [N208 9.7.3]
Returns the ulp of 64-bit one.
epsilon32:
Returns the ulp of 32-bit one.