Comments on Coercion, Rationals, Irrationals, Symbolic Math, Approximately Equals, and Numeric…
raiph_mellor
41

Good points as always. I didn’t state it explicitly in the article, but I noted in the comment above that I believe the sqrt(2)*sqrt(2) behavior is a trick on Perl 5’s part (as is any calculations of sqrt(n) * n). For all practical purposes — at least mine — it is of no consequence whether the result is exact or an approximation close to perfect. The only reason for testing this was whether Perl 6 passed Matt Parker’s fun calculator tests.

As for trying FatRat: The only thing I wanted to check here was whether FatRat had its own implementation of sin, using an internal “FatNum” type for the calculation. It did not. Julia has the Float128 type and Perl 5 can use bignum should that level of precision be necessary.

Personally I have no use for bignums, other than for demonstration purposes like this. Take my Cobol vs Perl 6 article where I implemented a version of Muller’s Recurrence. There I praised Perl 6’s Rats. But someone commented that even Rats will break given a high enough number of iterations. I have never read the Perl 6 specification, so I don’t know whether this is one the road map. But it seems to me there could be some use for a use bignum type of functionality in a case like that, for instance by using FatRats instead of Rats under the hood when declaring stuff like my $a = 1/9. The same goes for Nums.

At least it could have been useful in a just-for-fun article such as this :-)