Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: portably finding max integer

by shmem (Chancellor)
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://765944]
help
Chatterbox?
[hippo]: Yary: There are a few useful pointers in I need perl coding standards
[hippo]: ... and a boatload of good stuff in On Coding Standards and Code Reviews
[Yary]: Looking at system pm's, looks like it's "package" on the first line, then POD, then "use 5.xyz;use strict; use warnings; use modules..."
[Yary]: ah thanks for those links
[hippo]: Just bear in mind that all such ideas are subjective.
[choroba]: There might be a different standard at the shop you write the code for.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2018-01-23 16:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (250 votes). Check out past polls.

    Notices?