in reply to Re: Storing more decimal places in a variable
in thread Storing more decimal places in a variable

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.

  • Comment on Re^2: Storing more decimal places in a variable

Replies are listed 'Best First'.
Re^3: Storing more decimal places in a variable
by Zaxo (Archbishop) on Dec 16, 2004 at 20:49 UTC

    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';

    After Compline,
    Zaxo