If you want arbitrary precision rational arithmetic, you can use a FatRat

I didn't know about FatRats (yes, I know very little about perl6) - so I had a bit of a play (on rakudo-star-2017.07) and encountered confusing results:
> my $x = 1.111111111111111111111.FatRat; my $y = 1.111111111111111111 +111.Rat; $x - $y 0 > $x == $y True > say $x 1.111111111111111111111 > say $y 1.11111111111111111604544 >
On the bases that $x-$y==0 and $x==$y one is led to believe that $x and $y are exactly equivalent.
Yet, say() presents us with different values.

Are the 2 rationals equivalent ?
If so, then why does say() output different values ?
If not, then why do both $x-$y==0 and $x==$y evaluate as "True" ?

Interestingly, 1.11111111111111111604544 is the value of the double 1.1111111111111111 (16 decimal places) rounded to 23 decimals:
C:\>perl -le "printf '%.22e\n', 1.1111111111111111;" 1.1111111111111111604544e+000\n
Perhaps this ties in with:
> my $x = 1.111111111111111111111.FatRat; my $y = 1.1111111111111111.N +um; $x - $y 0 > $x == $y True
How does one coerce perl6 into displaying the actual numerator and denominator of these rationals ?

Cheers,
Rob

In reply to Re^3: Small Perl 6 discoveries II, Rats by syphilis
in thread [Perl6] Small discoveries I, __DATA__ by holli

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.