Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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


Comment on Re: Detecting ineger overflow
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://45952]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-09-20 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls