Problems? Is your data what you think it is? PerlMonks

### Re^7: Reasons for Using Perl 6

by Laurent_R (Canon)
 on Jan 03, 2018 at 20:01 UTC ( #1206625=note: print w/replies, xml ) Need Help??

in reply to Re^6: Reasons for Using Perl 6
in thread Reasons for Using Perl 6

The trouble with rationals is that the denominators keep growing.
Yes and no. It is true that there are cases where they do grow (but do you often add numbers like 132511/43 and 27/67 and 1024/853?), but there are many more cases where they don't. If you add or subtract many numbers in decimal format which most of us use everyday (monetary amount, physical measures made in the metric system, etc.) with, say two to five decimal places (or more), and the denominators will not grow and will often be a power of 10 (possibly multiplied by a power of 2 or a power of 5, something that can easily be brought back to a power of 10 by adjusting the numerator by the same factor). So in such cases, you'll never reach the 64-bit limit.

Replies are listed 'Best First'.
Re^8: Reasons for Using Perl 6
by Anonymous Monk on Jan 03, 2018 at 20:38 UTC
If you add or subtract many numbers in decimal format which most of us use everyday...
If what you really want is BigDecimal, why bother with a rational type at all?
I know about a BigDecimal class in Java, but I don't know about anything like that in Perl. Is there anything like that? Or perhaps you mean something derived from BigInt or BigRat?
I know about a BigDecimal class in Java, but I don't know about anything like that in Perl

Math::decNumber provides arbitrary precision decimal arithmetic.

Cheers,
Rob
Math::BigFloat seems to be doing decimal floating point, not binary, but I don't have much experience with it. There are a couple of other decimal modules on CPAN, but I know even less about them. The trouble with Perl's standard multiple-precision math modules is that they're overcomplicated and have some surprising behavior.

Create A New User
Node Status?
node history
Node Type: note [id://1206625]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2019-02-21 13:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
I use postfix dereferencing ...

Results (112 votes). Check out past polls.

Notices?