Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-09-23 00:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (209 votes), past polls