-
Notifications
You must be signed in to change notification settings - Fork 1
Floating point anomalies #6594
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
Comments
From sisyphus1@optusnet.com.auHi, Here are the specifics: $ perl6 --version =======
|
From @zoffixznetOn Wed, 11 Oct 2017 04:25:32 -0700, sisyphus wrote:
Eventually, yes. A bit lower on the priorities list at the moment, though. What you describe looks to be similar to the other issue I have in my private bug stash: say .1e0 + .2e0 == .3e0; # False And a brief look into guts suggests it's to do with the way our Nums are constructed during parsing. I was able to repro the issue with the C version of what we do in our Grammar: https://glot.io/snippets/eufyogt02g So yeah, the plan is to eventually address these. If you spot any more inconsistencies and weirdness, please report them. |
The RT System itself - Status changed from 'new' to 'open' |
From sisyphus1@optusnet.com.au-----Original Message-----
Yes, the anomaly with those particular values lies in the assignment of .3e0 $ perl -le 'print scalar reverse unpack "h*", pack "d<", 3 * 0.1;' $ perl -le 'print scalar reverse unpack "h*", pack "d<", 30 * 0.01;' At least, the calculation of 3.0e-1 produces produces the first value (which
That's good news.
Perl6's printf() function looks a little suspect - though I might be missing As with perl5's say function, doubles are rounded to 14 decimal digits of $ perl6 -e 'say 1.000000000000001e0;' $ perl -E 'say 1.000000000000001e0;' On perl5 we can get to see a more accurate rendition of the base 10 value $ perl -e 'printf "%.16e\n", 1.000000000000001e0;' But that doesn't work on perl6: $ perl6 -e 'printf "%.16e\n", 1.000000000000001e0;' Is there something amiss here ? Cheers, |
From @geekosaurOn Thu, Oct 12, 2017 at 5:31 AM, <sisyphus1@optusnet.com.au> wrote:
I question your use of 'accurate'. The low bits are *never* accurate. -- |
From sisyphus1@optusnet.com.auFrom: Brandon Allbery
To correct that assertion, they both of course round to 15 decimal digits of
I don't think there's anything "reasonable" about a printf() implementation $ perl6 -e 'printf "%.16e\n", Num(sqrt(3e0));' Perl6 knows quite well that a double assigned a value of $ perl6 -e 'say "not equivalent" if 1.7320508075688800e0 != Num(sqrt(3e0));' Furthermore, perl6 also knows quite well that a double assigned the value $ perl6 -e 'say "ok" if 1.7320508075688772e0 == Num(sqrt(3e0));' It's bad enough that perl5 and perl6 round to 15 decimal digits of $ perl -e 'printf "%.16e\n", sqrt(3.0);' As a feature request, it would also be nice to see "%a" formatting Cheers, |
From @geekosaurOn Fri, Oct 13, 2017 at 4:59 AM, <sisyphus1@optusnet.com.au> wrote:
I am wondering if youve talked to any Intel FP engineers. 17 decimal digits -- |
From @zoffixznetOn Fri, 13 Oct 2017 05:15:58 -0700, allbery.b@gmail.com wrote:
Perhaps the discussions about who talked to Intel engineers could be moved somewhere off the RT? The person fixing this ticket can figure out how much precision we can possibly give, without any luck wished upon those who made a feature request. |
From @GrimyHow to reproduce perl6 -e '$_ = 1e-1 + 2e-1; 3e-1; say $_ == 3e-1' perl6 -e '$_ = 1e-1 + 2e-1; .3e0; say $_ == 3e-1' Expected behavior Both scripts should give the same result. If I understand floating-point Both scripts should warn about the use of a floating-point literal in sink Actual behavior The first script prints `True`. The second script prints `False`. Both scripts correctly warn: `Useless use of constant floating-point number Version information This is Rakudo version 2017.09 built on MoarVM version 2017.09.1 This was discussed (shortly) on IRC: |
From @GrimyHow to reproduce perl6 -e 'my ($a, $b) = set(1e0), set(1e0 + 4e-15); say $a ~~ $b, Expected behavior Prints `False(False)`. Actual behavior Prints `True(False)`. This contradicts the documentation of the Setty ACCEPTS method: Note that other set methods show similar behavior: `1e0 � (1e0 + Version information This is Rakudo version 2017.09 built on MoarVM version 2017.09.1 |
From @zoffixznetOn Fri, 20 Oct 2017 08:02:12 -0700, victor.adam@derpymail.org wrote:
By accident, I merged incorrect ticket� If you're fixing original issue, ignore the stuff about set()s� For set() issue, it isn't to do with set()s but with .Str and .WHICH on a Num losing <Zoffix__> m: dd (1e0).Str, (1e0 + 4e-15).Str [1] https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127201 |
From @zoffixznetOn Fri, 20 Oct 2017 07:15:41 -0700, victor.adam@derpymail.org wrote:
This is the same cause as RT#132268. Merging there. |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznetOn Wed, 11 Oct 2017 04:25:32 -0700, sisyphus wrote:
Thank you for the report. All the issues mentioned in the ticket are now fixed. - The mentioned printf issues look to have been resolved as well, Fix: MoarVM/MoarVM@067c0594103a025 |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#132268 (status was 'resolved')
Searchable as RT132268$
The text was updated successfully, but these errors were encountered: