I see a heavy rounding error in (**)/2
. Whats the rounding mode
when the arguments are float? Here you see the discrepancy:
?- X is float(3333**10).
X = 1.6918160339379514e+35.
?- X is 3333.0**10.0.
X = 1.6918160339379518e+35.
Its quite pronounced, more than 50%:
/* SWI-Prolog 8.5.17 */
?- aggregate_all(count, (between(1,1000000,N),
float(N)**10.0 =\= float(N**10)), C).
C = 585342.
I don’t see this extreme discrepancy in my system:
/* Jekejeke Prolog 1.5.4, JDK 19 */
?- aggregate_all(count, (between(1,1000000,N),
float(N)**10 =\= float(N^10)), C).
C = 551.
Has this something to do with te clpBNR flags? Or maybe
an issue with (=\=)/2
? The discrepancy is a little surprise,
wasn’t prepared for that.
Edir 21.09.2022
Scryer Prolog isn’t that lucky either. Trealla Prolog is a
little bit more lucky:
/* Scryer Prolog 0.9.0 */
?- aggregate_all(count, (between(1,1000000,N),
float(N)**10 =\= float(N^10)), C).
C = 500254.
/* Trealla Prolog 2.2.5 */
?- aggregate_all(count, (between(1,1000000,N),
float(N)**10 =\= float(N^10)), C).
C = 12750.