Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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.

Comment on Re: portably finding max integer
Download Code

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 having an uproarious good time at the Monastery: (9)
As of 2015-11-26 10:16 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (697 votes), past polls