in reply to Re^2: Small Perl 6 discoveries II, Rats
in thread [Perl6] Small discoveries I, __DATA__

If the Rat class isn't any more accurate than a Num, but it's much slower, then what purpose does it serve?
  • Comment on Re^3: Small Perl 6 discoveries II, Rats

Replies are listed 'Best First'.
Re^4: Small Perl 6 discoveries II, Rats
by bduggan (Pilgrim) on Oct 19, 2017 at 16:02 UTC
    Well -- I'd say it is more accurate (though not more precise) -- it can accurately represent rational numbers, so you can do rational arithmetic without rounding errors. e.g.
    > .3.Num - .2.Num - .1.Num == 0 False > .3 - .2 - .1 == 0 True
      The reason this digression started is because it can't accurately represent rational numbers. Except for trivial examples, I suppose.