martin has asked for the wisdom of the Perl Monks concerning the following question:
# solution 1 use Config; if ($Config{'use64bitint'}) { # max_integer is probably 2**63-1 } else { # max_integer is probably 2**31-1 }
Both solutions seem to work on UNIX/i386 machines I have access to. But how portable is either one? Is there a better way? In case of doubt my module should rather assume a smaller value than risk loss of precision when perl internally switches to floating point. Would 2147483647 (2**31-1) be an integer value for any perl (5.6 or higher) on any platform out there?# solution 2 my $max_int = (-1)>>1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: portably finding max integer
by shmem (Chancellor) on May 24, 2009 at 18:02 UTC | |
|
Re: portably finding max integer
by BrowserUk (Patriarch) on May 24, 2009 at 20:57 UTC | |
by martin (Friar) on May 25, 2009 at 14:07 UTC | |
by tye (Sage) on May 25, 2009 at 14:33 UTC | |
|
Re: portably finding max integer
by jwkrahn (Abbot) on May 24, 2009 at 18:34 UTC |