Section "magnitude"

We support predicates that compare numbers by their magnitude, looking only at the value and not at the type. This is in contrast to Prolog unification (=)/2 or Prolog syntactic equality (==)/2 which both take the value and the type into account, whereas (=:=)/2 does convert integer arguments to float before comparison, if at least one argument is float.

We provide literals 0rNaN, 0rInf and -0rInf for not a number, positive and negative infinity respectively. These special values are considered Prolog numbers, that are neither interger nor float. The special values are understood by the evaluable functions (-)/2, min/3 and max/3 and by the predicates (=:=)/2, (<)/2, etc.. Otherwise special values cause an error.

The following magnitude evaluable functions are provided:

abs(A, B): [ISO 9.1.7]
The predicate succeeds in B with the absolute value of A.
sign(A, B): [ISO 9.1.4]
The predicate succeeds in B with the sign of A.
min(A, B, C): [TC2 9.3.9]
The predicate succeeds in C with the minimum of A and B.
max(A, B, C): [TC2 9.3.8]
The predicate succeeds in C with the maximum of A and B.
truncate(A, B): [ISO 9.1.7]
The predicate succeeds in B with the truncate of A.
floor(A, B): [ISO 9.1.7]
The predicate succeeds in B with the floor of A.
ceiling(A, B): [ISO 9.1.7]
The predicate succeeds in B with the ceiling of A.
round(A, B): [ISO 9.1.7]
The predicate succeeds in B with the rounding of A.
inf(A):
The predicate succeeds in A with the positive infinity.
nan(A):
The predicate succeeds in A with the not a number.

The following magnitude predicates are provided:

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

Use Privacy (c) 2005-2026 XLOG Technologies AG