So I cannot use 1.0Inf to speed-up my max/min aggregate?
What about not requiring a flag for the special case of
positive and negative Infinity?
Edit 13.10.2024
Interestingly JavaScript somehow has two behaviours.
I also find the following:
> 10 ** 400 < Infinity
false
This is becaue 10 ** 400 evaluates to Infinity, and
Infinity < Infinity is false. But in SWI-Prolog the expression
10^400 doesn’t evaluate to Infinity, the conversion to
The issue is the interpretation of inf. Is it true infinity or merely “some value larger than max float”. In the first case 10^400 is smaller, else it is undecided. Numerical comparison promotes the rational to a float first.
You can also use the standard order of terms. In SWI-Prolog this handles all numerical types in one space and it does the same as cmpr for mixed rational/float comparison. See SWI-Prolog -- Standard Order of Terms
Is there a maxr/2 and minr/2? Actually there is
in SWI-Prolog, Oki Doki! It even works as desired:
?- X is maxr(10^400,inf).
X = 1.0Inf.
BTW: For example there is an other programming language
that also took the route like JavaScript. In particular
in Python also features Infinity and I get again:
A middle ground would be to not have exact float bigint comparison
by default. But by default only exceptional handling for infinity
float bigint comparison inside inexact comparison.