On Wed, 11 Oct 2017 04:25:32 -0700, sisyphus wrote: > Hi, > Some anomalous rounding behaviour on Ubuntu-16.04 was noted at > http://www.perlmonks.org/?node_id=1200326 > > Here are the specifics: > > $ perl6 --version > This is Rakudo version 2017.07 built on MoarVM version 2017.07 > implementing Perl 6.c. > > ======= > Issue 1 > ======= > > $ perl6 -e 'say Int(2e25);' > 20000000000000001811939328 > $ perl6 -e 'say Int(20e24);' > 19999999999999997516972032 > > That seems odd because 2e25 and 20e24 are exactly equivalent. > > ======= > Issue 2 > ======= > > $ perl6 -e 'say "WTF" if 1.000000000000001e0 == 1e0;' > WTF > > That seems odd because 1.000000000000001e0 and 1e0 are quite different > double precision values. According to perl5: > > $ perl -le 'print scalar reverse unpack "h*", pack "d<", > 1.000000000000001e0;' > 3ff0000000000005 > $ perl -le 'print scalar reverse unpack "h*", pack "d<", 1e0;' > 3ff0000000000000 > > Is it the intention of the perl6 developers that such discrepancies will be > addressed ? > > Cheers, > Rob
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, even though no work to printf itself was done. - Somehow fixing Num stringification alone fixed the `1.000000000000001e0 == 1e0` bug. That was surprising and I filed https://github.com/rakudo/rakudo/issues/1647 to investigate that further - Support for '%a' in sprintf was mentioned in the ticket, but I suggest if there's real interest for that format, a separate ticket to be opened - There a Num-involved precision issue with drift in Str->Num->Str chains, filed as https://github.com/rakudo/rakudo/issues/1651 Fix: https://github.com/MoarVM/MoarVM/commit/067c0594103a025 https://github.com/MoarVM/MoarVM/commit/8841c4241b4faa8 https://github.com/MoarVM/MoarVM/commit/af2eb8a7f7d4344 https://github.com/MoarVM/MoarVM/commit/4d3fc2818d0032b https://github.com/rakudo/rakudo/commit/8422d7b4e23678b https://github.com/rakudo/rakudo/commit/a2a2a745c4242d1 Test: https://github.com/perl6/roast/commit/01d02dafb6 https://github.com/perl6/roast/commit/b6d5364fe0 https://github.com/perl6/roast/commit/855af84f82 https://github.com/perl6/roast/commit/f4a6c635f4 https://github.com/perl6/roast/commit/d1faf1d049