Re:Ask HN: Why hasn't Perl 6 taken off yet?
by espadrine on Monday November 07, 2016 @12:30PM
(#12892882)
For the sake of exhaustivity, let's point out that numeric literals in Perl6 separate rationals (Rat) and floating-point numbers (Num), which means the first Perl6 example would work as intended provided we stick with Rat:
Rationals represent numbers of the form a÷b, with a a bigint and b a 64-bit integer. When b gets too big for that fast representation, it gets converted to a Num (ie, IEEE 754).
> (1 / (10 ** 100)).WHAT
(Num)
That tradeoff is reasonable, as numbers that cannot be represented this way are very likely to be non-rational math (eg, sqrt, exp, sin, pi, that kind of thing). For money, this is safe. For real numbers, well:
> sin(0).WHAT
(Num)
FatRat uses a bigint for b. Obviously, it still cannot accurately represent non-rational numbers such as pi.
Re:Ask HN: Why hasn't Perl 6 taken off yet?
by acdha on Monday November 07, 2016 @02:01PM
(#12893829)
Thanks! I definitely hope my point didn't come across as “this is terrible” rather than “people for whom this is critical still need to read the docs / write tests”.
Reference: https://docs.perl6.org/language/syntax#Number_literals https://docs.perl6.org/type/Rat