Scientific notation (such as 1e-1 for 1×10-1) always produces a
floating-point Num in Perl 6. For reasons I don’t understand, however, they
sometimes seem to add up as rationals, rather than floating-point:
> 0.1e0 + 0.2e0 == 0.3e0
> 1e-1 + 2e-1 == 3e-1
Maybe someone can explain the discrepancy to me in a polite email. Anyway,
I wholeheartedly endorse Perl 6’s use of rational numbers for exact
arithmetic, and I think more languages could benefit from a similar
implementation. For reference, Julia and Haskell have built-in rationals,
constructed (respectively) with the // and % operators; most other
languages have them as a library, if at all, without support for literals.
Is this a surprise? Is there an explanation?
608 658-1890 cell
608 261-5738 wk