$ say 3602879701896397/36028797018963968 == 0.100000000000000006;
True
Have they changed the spec ?
> say 3602879701896397/36028797018963968 == 0.100000000000000006;
False
I have:
$ raku -v
Welcome to Rakudo(tm) v2021.03.
Implementing the Raku(tm) programming language v6.d.
Built on MoarVM version 2021.03.
If the RHS is a rational, then it's fairly easy to show that 3602879701896397/36028797018963968 != 100000000000000006/1000000000000000000.
(A/B == C/D if and only if A*D == B*C. In this case, A*D ends in zero and B*C ends in 8 so the equivalence cannot possibly hold.)
If the RHS is a double, then it's correct that 3602879701896397/36028797018963968 == 0.100000000000000006.
However, the 3 doubles assigned (respectively) the 3 values 0.100000000000000006, 0.10000000000000001 and 0.1 are all exactly the same.
So we find, as expected:
> say 3602879701896397/36028797018963968 == 0.100000000000000006e0;
True
> say 3602879701896397/36028797018963968 == 0.10000000000000001e0;
True
> say 3602879701896397/36028797018963968 == 0.1e0;
True
I've long been curious about the mindset that has created the rational/double arithmetic on raku, and I had thought (hoped) it might be a simple task to see how it all fits together.
Alas no, and I'm starting to see that I'm going to have to locate and work through the relevant documentation if I ever want to understand it.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.