Re:A little thing to love about Perl 6 and COBOL
by xioxox on Thursday February 05, 2015 @11:44AM
(#9004178)
Is this kind of mixed rational/floating point sensible? It seems to be a fuzzy do-what-I-mean, not what-I-say kind of arithmetic. Surely weird differences in algorithm behaviour might occur around the 64 bit integer limit. It will also make the analysis and testing of numerical algorithm accuracy very difficult unless you can put bounds on your input values.
Re:A little thing to love about Perl 6 and COBOL
by leoh on Thursday February 05, 2015 @02:23PM
(#9005299)
I feel like this "do what I mean not what I say" is exactly what I have found so irksome about Perl
Re:A little thing to love about Perl 6 and COBOL
by kbenson on Thursday February 05, 2015 @11:53AM
(#9004267)
I think the point is that it does what what you mean in the majority of cases. If you know you are going to need specific functionality such as floats or large rationals, specify the type of your variables up front. This is an are where the optional type system can help.
Re:A little thing to love about Perl 6 and COBOL
by omaranto on Thursday February 05, 2015 @12:00PM
(#9004313)
I like that the first thing the documentation says is that "class FatRat is Cool". :)
Being cool seems to mean having automatic conversion to and from strings: http://doc.perl6.org/type/Cool
There is a feature in Perl 6 that the OP didn't mention: if the denominator doesn't fit into a 64 bit integer anymore, it falls back to floating point arithmetic.
There's a type (FatRat, http://doc.perl6.org/type/FatRat) that stays precise if you really want, but the default give precise arithemtics for "usual" numbers without pathologic slow-down for pathologic cases.