-
Notifications
You must be signed in to change notification settings - Fork 134
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
format("~0f",[1.4]) incorrect #2779
Comments
I would personally expect Rust also only prints |
Neither |
|
That is quoting one phrase out of context. The entire paragraph for
Please do not confuse the concrete syntax (the actual characters) with the precision as such. Since floating point numbers have to have at least one digit before and after the dot, all floats will occupy at least three characters. |
|
Note already that
So your second example is unrelated to rounding in For your first example, SICStus (as expected):
If you want
|
Ok, I see. I thought format just cut or chop off or fill up digits from results already 'calculated'. Looks like format/2 as such is problematic
|
SWI is right here! Please note that floats have 52/53 bits for the mantissa. And since the number is printed in base 10 (which has 2 and 5 as factors), you still need that many decimal digits to write out the actual value in full. Usually, the output is rounded to the shortest value (or one of them) that still produces the very same value (when read back). |
All right! IEEE 754 Standard (0.99999999999999972 and 0.99999999999999962 are identical).. |
It should round accordingly. Thus 1.0
Not in Prolog. |
I should correct myself. This is not the case for numbers very close to zero. There, even more digits are required. In fact, the smallest positive number is: 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049406564584124654417656879286822137236505980261432476442558568250067550727020875186529983636163599237979656469544571773092665671035593979639877479601078187812630071319031140452784581716784898210368871863605699873072305000638740915356498438731247339727316961514003171538539807412623856559117102665855668676818703956031062493194527159149245532930545654440112748012970999954193198940908041656332452475714786901472678015935523861155013480352649347201937902681071074917033322268447533357208324319360923828934583680601060115061698097530783422773183292479049825247307763759272478746560847782037344696995336470179726777175851256605511991315048911014510378627381672509558373897335989936648099411642057026370902792427675445652290875386825064197182655334472656250000 |
The only other Prolog I can see correct then is CxProlog. Everything else is wrong (including Logtalk @pmoura). |
Which rounding method should be the default?
|
This is very odd. Practically all systems including SICStus up to 3.9 print an integer, when we are asking for a float ....
The text was updated successfully, but these errors were encountered: