From Newsgroup: comp.lang.prolog
minimumNumber/maximumNumber which do propagate NaN.
Actually the suffix rCLNumberrCY in the name indicate
that they donrCOt propagate NaN unless both arguments
are NaN, the ones that propagate NaN are still
rCLminimumrCY and rCLmaximumrCY without rCLNumberrCY suffix.
See IEEE754_ver2019.pdf, you can choose at least between:
9.6 Minimum and maximum operations
sourceFormat minimum(source, source)
sourceFormat minimumNumber(source, source)
sourceFormat maximum(source, source)
sourceFormat maximumNumber(source, source)
I have tried to track my design choice so far and got:
The built-in (=\=)/2 now implements
not quiet IEEE 754-2019 -o5.6.1.
The built-ins (=:=)/2, (<)/2, etc. now implement
quiet IEEE 754-2019 -o5.6.1.
The built-ins (@<)/2, etc. now implement
quiet ordered IEEE 754-2019 -o5.6.1.
The built-in (-)/2 now implements
NaN propagation IEEE 754-2019 -o6.2.3.
The built-ins min/3 and max/3 now implement
number IEEE 754-2019 -o9.6.
I didnrCOt touch arithmetic functions or trigonometric
functions yet, they still bark on special values.
Only tried to have a clean cut solution for ordering
releated stuff, that uses special values, which
has less coverage in the ECLiPSe document, and
albeit arbitrary choices were made, some choices
are inspired by what is found in other languages
such as JavaScript, Python and Java, other choices are
inspired to have a natural order,
disagreeing with SWI and ECLiPSe:
/* Version 7.1beta #13 (x86_64_nt) */
[eclipse 1]: ?- sort([0, 0.0, 1.5NaN, -1.0Inf, 1.0Inf], X).
X = [1.5NaN, -1.0Inf, 0.0, 1.0Inf, 0]
/* SWI-Prolog (threaded, 64 bits, version 10.1.1) */
?- sort([0, 0.0, 1.5NaN, -1.0Inf, 1.0Inf], X).
X = [1.5NaN, -1.0Inf, 0.0, 0, 1.0Inf].
/* Dogelog Player 2.2.1 */
?- sort([0, 0.0, 0rNaN, -0rInf, 0rInf], X).
X = [-0rInf, 0.0, 0, 0rInf, 0rNaN].
One can still see ISO core standard typical things,
like 0 \\== 0.0. That NaN is bigger than 0.0 in total
order comes from IEEE 754-2019 -o5.6.1. SWI Prolog adopts
finite float and integer ordered together surrounded
by special values, while ECLiPSe Prolog does not do that.
Mild Shock schrieb:
Hi,
Somehow this link is broken ( Not Found ):
*0106.0 Float enhancements Draft* https://prolog-lang.org/ImprovementsForum/0106-floats-enhancements.html
Also there is no consensus between ECLiPSe and SWI in realization:
```
/* Version 7.1beta #13 (x86_64_nt) */
[eclipse 5]: X is min(1.5NaN, 3).
X = 3.0
Yes (0.00s cpu)
[eclipse 6]: X is min(3, 1.5NaN).
X = 1.5NaN
Yes (0.00s cpu)
/* SWI-Prolog (threaded, 64 bits, version 10.1.1) */
?- X is min(1.5NaN, 3).
X = 1.5NaN.
?- X is min(3, 1.5NaN).
X = 1.5NaN.
```
Mostlikely SWI uses IEEE minimum. While ECLiPSe uses (a < b ? a : b).
Bye
P.S.: I am planning a kind of IEEE minNum behaviour:
```
/* Dogelog Player 2.2.1 */
?- X is min(0rNaN, 3).
X = 3.
?- X is min(3, 0rNaN).
X = 3.
```
Note that there is no coercion of 3 into 3.0.
Mild Shock schrieb:
Hi,
Functional requirement:
?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
-a-a-a L == [C,D].
?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
-a-a-a L == [A,B,C,D].
Non-Functional requirement:
?- member(N,[5,10,15]), time(singletons(N)), fail; true.
% Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
true.
Can your Prolog system do that?
P.S.: Benchmark was:
singletons(N) :-
-a-a-a hydra2(N,Y),
-a-a-a between(1,1000,_), term_singletons(Y,_), fail; true.
hydra2(0, _) :- !.
hydra2(N, s(X,X)) :-
-a-a-a M is N-1,
-a-a-a hydra2(M, X).
Bye
--- Synchronet 3.21f-Linux NewsLink 1.2