Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: portably finding max integer

by shmem (Canon)
on May 24, 2009 at 18:02 UTC ( #765944=note: print w/replies, xml ) Need Help??

in reply to portably finding max integer

The following seems to be accurate

$max_unsigned_int = ~0; $max_signed_int = -1 >> 1;

according to perlop:

Unary "~" performs bitwise negation, i.e., 1ís complement. For example, "0666 & ~027" is 0640. (See also "Integer Arithmetic" and "Bitwise String Operators".) Note that the width of the result is platform-dependent: ~0 is 32 bits wide on a 32-bit platform, but 64 bits wide on a 64-bit platform, so if you are expecting a certain bit width, remember to use the & operator to mask off the excess bits.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2016-10-25 08:50 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (315 votes). Check out past polls.