Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2016-10-23 10:16 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (301 votes). Check out past polls.