Hacker News new | past | comments | ask | show | jobs | submit login

> Several of the results surprised me. Did they surprise you?

Well, the perl6 result surprised me, since that means it's using something more precise than double precision floating point :)




They're called Rat (for Rational number): https://docs.perl6.org/type/Rat , which maintain precision until the denominator exceeds 64 bits: then they're downgraded to doubles. If you want to keep precision still at that level, you can use FatRat: https://docs.perl6.org/type/FatRat


It surprised me too, since it's not what I got.

    $ perl6 --version
    This is Rakudo version 2018.03 built on MoarVM version 2018.03
    implementing Perl 6.c.
    $ perl6 -e 'print 9999999999999999.0-9999999999999998.0;print "\n";'
    2
    $
(Incidentally, I would have used "say" rather than "print" with an explicit newline.)


Indeed, there was a bug with determining when to switch to floats, that was fixed by Zoffix in August:

    https://github.com/rakudo/rakudo/commit/fec1bd74f97e257d4c88673cd62fdcae39f587a3


  › perl6 -e '.say for $*PERL.compiler, 9999999999999999.0-9999999999999998.0'
  rakudo (2018.11)
  1




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: