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?
| [reply] |
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
| [reply] |
OK, thank you, I had not heard about that module before.
| [reply] |
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.
| [reply] |
The trouble with Perl's standard multiple-precision math modules is that they're overcomplicated and have some surprising behaviour.
In my limited experience with these modules I've found them to be well behaved as long as they're loaded with 'use Math::BigInt', 'use Math::BigFloat', 'use Math::BigRat'.
I regard this as the sane way to load these modules.
Start loading them with 'use bignum', 'use bigint', etc. (which I regard as the insane way) and they can get a bit tricky - I think largely because variables might not always be what you think they are.
If you have some examples of surprising behaviour when loading is done "sanely" then it's probably worth presenting them here.
(But, please, not buried in this thread. Instead create a new thread.)
I regard the major drawback to the standard multi-precision math modules as being their speed. However, speed is not always terribly important.
And, yes, those modules are doing decimal arithmetic.
Another decimal module that might be worth trying is Math::decNumber. I haven't got around to testing it yet, as it requires the decNumber C library - but trying it out is definitely on my todo list.
Cheers, Rob
| [reply] |