Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounding glitch from bigint to float #77

Open
Jean-Luc-Picard-2021 opened this issue Oct 21, 2022 · 1 comment
Open

Rounding glitch from bigint to float #77

Jean-Luc-Picard-2021 opened this issue Oct 21, 2022 · 1 comment
Labels

Comments

@Jean-Luc-Picard-2021
Copy link

Jean-Luc-Picard-2021 commented Oct 21, 2022

SWI-Prolog has released a new release 8.5.20 with better
float rounding. Comparing we found:

/* SWI-Prolog 8.5.20 Ok */
?- X is float(166153499473114502559719956244594689).
X = 1.6615349947311452e+35.

/* Ciao Prolog Nok */
?- X is float(166153499473114502559719956244594689).
X = 1.661534994731145e35 ?

Our guess is that this conversion routine doesn't work
for HALF_EVEN mode:

flt64_t bn_to_float(bignum_t *bn) {
while (i > 1) {
f = f*norm2 + u;
https://github.com/ciao-lang/ciao/blob/master/core/engine/eng_bignum.c#L1043
@jfmc
Copy link
Member

jfmc commented Jul 29, 2023

Python

>>> float(166153499473114502559719956244594689)
1.6615349947311452e+35
>>> 

Javascript

> 166153499473114502559719956244594689
1.6615349947311452e+35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants