Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Detecting ineger overflow

by quidity (Pilgrim)
on Dec 10, 2000 at 21:07 UTC ( #45952=note: print w/replies, xml ) Need Help??

in reply to Detecting ineger overflow

You should be able to work out if you are going to get an overflow by comparing the result with the largest possible integer value for your system. Then you can fall through to using BigInt's.

You would be clearer by using Math::BigInt thoughout for all integer values. This allows you to use integers of arbitary size (given certain memory requirements, of course). Math::BigInt . It allows you to overload all mathematical operators when integers are declared using the format below:

use Math::BigInt; $i = new Math::BigInt '123 456 789 123 456 789';

Replies are listed 'Best First'.
Re (tilly) 2: Detecting ineger overflow
by tilly (Archbishop) on Dec 10, 2000 at 23:23 UTC
    Have you benchmarked it?

    Math::BigInt is abysmal on performance. Something about on every operation parsing a string into an array of integers, doing your operation, then coercing that back into a string...

    Try it if you don't believe me.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://45952]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2017-05-30 07:18 GMT
Find Nodes?
    Voting Booth?