Thank you very much :P
now just to nag my webserver to install it...
and a quick question on syntax for Math::BigFloat :
first of all, if I say "Math::BigFloat->precision(5);" it will only apply to results from "$x->bmul($y);" etc., correct?
thanks again for your prompt help :P | [reply] |
The docs say "All operators (inlcuding basic math operations) are overloaded", which means it should work work *, +, etc. (provided one of the operands is of class Math::Float). Try and find out.
| [reply] |
use Math::BigFloat;
Math::BigFloat->accuracy(200);
$x = Math::BigFloat->new(2);
print $x->bsqrt();
-- All code is 100% tested and functional unless otherwise noted.
| [reply] [d/l] |
If using BigFloat or BigInt, be mindful that they are SLOW. They can handle 'big' numbers because they're not bound by the word-length limitations of your CPU's add/sub/mul/div instructions, as they implement their own versions in perl storing the data in encoded strings. Trouble is, there's an awful lot of overhead in doing this.
I have some code which uses BigInt (it's in Net::CIDR, for dealing with IPv6 addresses) and even taking account of the fact that the BigInt version deals with more data than the int version, it still runs at of the order of 1/100th to 1/1000th or worse of the speed. | [reply] |
It doesn't sound as though the OP's application needs blazing speed for MP arithmetic. In any case, Math::BigFloat's speed can be improved by using an external library like Pari or GMP, eg.
use Math::BigFloat lib => 'GMP';
| [reply] [d/l] |