Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

On a problem of float/1 for big nums

96 views
Skip to first unread message

Harry Stoteles

unread,
Dec 6, 2016, 1:07:33 PM12/6/16
to
Does your Prolog system do high fidelity float/1
for big nums or not?

Unfortunately the ISO core standard doesn't prescribe
a particular rounding function in its current form.

But it is clear that rounding down to zero has a greater
and hence worse average error than rounding to the nearest.

Today most I/O routines that can read decimals do rounding
to the nearest. But what about the float/1 evaluable function?

Here are some test cases:

SWI-Prolog and ECLiPSe Prolog (sic!):

?- X is float(244124086793065425827).
X = 2.441240867930654e+20.

?- X is 244124086793065425827.0.
X = 2.4412408679306543e+20.

?- X is float(244124086793065425827)-244124086793065425827.0.
X = -32768.0.

Jekejeke Prolog:

?- X is float(244124086793065425827).
X = 2.4412408679306543E20

?- X is 244124086793065425827.0.
X = 2.4412408679306543E20

?- X is float(244124086793065425827)-244124086793065425827.0.
X = 0.0

In my opinion float/1 would be better off, if it would use
round to nearest instead of something else.

Ulrich Neumerkel

unread,
Dec 13, 2016, 5:32:40 PM12/13/16
to
Harry Stoteles <in...@xlog.ch> writes:
>Does your Prolog system do high fidelity float/1
>for big nums or not?
>
>Unfortunately the ISO core standard doesn't prescribe
>a particular rounding function in its current form.
>
>But it is clear that rounding down to zero has a greater
>and hence worse average error than rounding to the nearest.
>
>Today most I/O routines that can read decimals do rounding
>to the nearest. But what about the float/1 evaluable function?

Excellent find!

The evaluable functor float/1 uses the implementation defined
floating point rounding function (9.1.4.1) ; the very same function
is used by all mixed mode operations (8.1.5).

However, when reading a floating point number, no explicit
rounding function is defined. So it is left undefined
which of the usual two float values should be used.
Probably, the same rounding function of 9.1.4.1 should
be used. Then the mentioned difference would not show.


http://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#floatreadrounding





burs...@gmail.com

unread,
Dec 13, 2016, 9:43:27 PM12/13/16
to
> http://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#floatreadrounding

Thanks for doing the testing.

P.S.: H.S. is me, and its a joke on some Greek
philosopher, who lived from 384 BC to 322 BC

P.P.S.: In Google groups when posting there is a
function, you can change the user name on per post basis

P.P.P.S.: The observation is a result of the below finding,
maybe we should also check the (/)/2 evaluable function:

https://github.com/SWI-Prolog/swipl-devel/issues/183

burs...@gmail.com

unread,
Dec 14, 2016, 9:07:34 AM12/14/16
to
Am Mittwoch, 14. Dezember 2016 03:43:27 UTC+1 schrieb burs...@gmail.com:
> > http://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#floatreadrounding
> Thanks for doing the testing.

I cannot verify the results for ECLiPSe Prolog.
On source forge or somewhere else there is no
verrsion 6.2 of ECLiPSe Prolog as of now.

You testing with some non-public version? Wouldn't
be the first time you publish such results here.
I only get:

Version 6.1 #224 (x86_64_nt), Fri Nov 25 19:15 2016
[eclipse 1]: writeq(
244124086793065425827.0).
2.4412408679306543e+20
Yes (0.00s cpu)
[eclipse 2]: X is 244124086793065425827
-244124086793065425827.0.

X = -32768.0
Yes (0.00s cpu)
[eclipse 3]:

burs...@gmail.com

unread,
Dec 14, 2016, 9:10:53 AM12/14/16
to
I see some dev version, but its number is 7.0#10:

http://eclipseclp.org/Distribution/Dev/7.0_10/i386_nt/

Maybe I should try the above. Just a sec.

burs...@gmail.com

unread,
Dec 14, 2016, 9:18:15 AM12/14/16
to
And version Version 7.0development #11 (x86_64_nt),
Thu Nov 17 15:51 2016 doesn't do the job either.

Ulrich Neumerkel

unread,
Dec 14, 2016, 1:34:08 PM12/14/16
to
burs...@gmail.com writes:
>Am Mittwoch, 14. Dezember 2016 03:43:27 UTC+1 schrieb burs...@gmail.com:
>> > http://www.complang.tuwien.ac.at/ulrich/iso-prolog/stc#floatreadrounding
>> Thanks for doing the testing.
>
>I cannot verify the results for ECLiPSe Prolog.
>On source forge or somewhere else there is no
>verrsion 6.2 of ECLiPSe Prolog as of now.

Version 6.2development #21 (x86_64_linux), Wed May 27 20:58 2015

burs...@gmail.com

unread,
Dec 14, 2016, 2:08:36 PM12/14/16
to
Unexpectedly there seems to be a
difference between the 64-bit version
and the 32-bit version of ECLiPSe (Prolog).

Via the 32-bit version I get the same
result as in Ulrichs list:

Version 6.1 #224 (i386_nt), Fri Nov 25 19:15 2016
[eclipse 1]: writeq(244124086793065425827.0).
2.4412408679306543e+20
Yes (0.00s cpu)
[eclipse 2]: X is 244124086793065425827-244124086793065425827.0.

X = 0.0
Yes (0.00s cpu)
[eclipse 3]:

This was communicated by Joachim Schimpf, ECLiPSe
maintainer. Not a big deal, a reason I am using
ECLiPSe here and then, besides being an excellent

Prolog system, is that it is maintained!

Ciao Prolog stalled at 2013-06-12 ??
YAP Prolog stalled at 2013-01-20 ??

Ulrich Neumerkel

unread,
Dec 15, 2016, 9:56:52 AM12/15/16
to
burs...@gmail.com writes:
>Ciao Prolog stalled at 2013-06-12 ??
>YAP Prolog stalled at 2013-01-20 ??

As far as I know:

YAP: 2016-04-22

Ciao: 2016-11-15

Harry Stoteles

unread,
Dec 15, 2016, 12:14:14 PM12/15/16
to
Am Donnerstag, 15. Dezember 2016 15:56:52 UTC+1 schrieb Ulrich Neumerkel:
> Ciao: 2016-11-15

Nope, not from here as of todsy:
http://ciao-lang.org/download_latest.html
Following the link it says: CiaoDE 1.15-1781-g328b907
(released on 2013-06-12 16:45:13 +0200)

Where exactly?

> YAP: 2016-04-22

Nope, not from here as of todsy:
http://www.dcc.fc.up.pt/~vsc/Yap/downloads.html
Following the link it says Windows
64-bit version 6.3.2

Where exactly?

BTW: I dont have a C compiler...

P.S.: Using my Harry Stoteles account, since Google groups
has a posting limit, and I was already active elsewhere.

burs...@gmail.com

unread,
Dec 16, 2016, 3:47:12 AM12/16/16
to
Am Donnerstag, 15. Dezember 2016 18:14:14 UTC+1 schrieb Harry Stoteles:
> Where exactly?
>
> BTW: I dont have a C compiler...

For example the Prolog FAQ doesnt distinguish between
binary available and source available, the FAQ only
writes the following:

Ciao 1.4
+ Available: http://ciao-lang.org

Yap 4.2.0
+ Available: http://www.ncc.up.pt/~vsc/Yap/

And well, this would be too much work, it mentions
old release numbers, maybe leave off the release numbers
alltogether in the FAQ.

What is the relevant release number anyway, many Prolog
systems have stabel and develop versions. Maybe
even different releases for 32-bit and 64-bit.

Markus Triska

unread,
Dec 16, 2016, 1:22:29 PM12/16/16
to
burs...@gmail.com writes:

> And well, this would be too much work, it mentions
> old release numbers, maybe leave off the release numbers
> alltogether in the FAQ.
>
> What is the relevant release number anyway, many Prolog
> systems have stabel and develop versions. Maybe
> even different releases for 32-bit and 64-bit.

I agree. I will soon rework this whole section and post a few changes
for further discussion.

Thank you for looking into this!

All the best,
Markus

--
comp.lang.prolog FAQ: http://www.logic.at/prolog/faq/

Julio Di Egidio

unread,
Dec 17, 2016, 12:31:21 AM12/17/16
to
On Tuesday, December 6, 2016 at 7:07:33 PM UTC+1, Harry Stoteles wrote:
> Does your Prolog system do high fidelity float/1
> for big nums or not?
>
> Unfortunately the ISO core standard doesn't prescribe
> a particular rounding function in its current form.

It's rather unfortunate that the standard got bogged down into defining
arithmetic types, in fact into defining any types at all.

That said, in every floating-point system, including the ubiquitous IEEE 754,
there are several rounding modes, and a *correct* implementation SHOULD provide:

1) predicates that take a rounding mode as a parameter for full user control;

2) (optionally) predicates that default the rounding mode to the rounding
mode that is currently set at FPU level;

3) (optionally) predicates that default the rounding mode to banker's rounding.

While 3 could be the default and certainly is the most common option, note
that without 1 or at least 2 some algorithms/systems become simply impossible
to implement (correctly). (And, with 2 but without 1, they can be implemented
but at the prohibitive performance cost of out-of-band native calls.)

Julio

burs...@gmail.com

unread,
Dec 17, 2016, 7:53:30 AM12/17/16
to
Am Freitag, 16. Dezember 2016 09:47:12 UTC+1 schrieb burs...@gmail.com:

> Yap 4.2.0
> + Available: http://www.ncc.up.pt/~vsc/Yap/

Its not ncc, but dcc.

Also there is some craze going on, there a two sites:

YAP-6 Documentation
http://www.dcc.up.pt/~vsc/yap/

:- Stable Version
http://www.dcc.fc.up.pt/~vsc/Yap/

Note the difference in lower case and upper case of y.

0 new messages