Abigail on Mon, 1 Jul 2002 06:10:31 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Large integers


On Fri, Jun 28, 2002 at 11:19:33AM -0500, Walt Mankowski wrote:
> On Fri, Jun 28, 2002 at 11:58:17AM -0400, Eric Roode wrote:
> > Hello all,
> >
> >     Can a Perl program tell whether it has 64-bit integers available
> > to it, and modify its behavior accordingly?
>
> This looks like it should work, but I don't have a 64-bit machine to
> test it on:
>
> use Config;
> if ($Config{intsize} == 8) {
>    print "Perl is using 64-bit integers\n";
> }


But it doesn't. It tells you the size of the native integers of
your hardware, which isn't the same as Perl having 64 bit integers
available.
 
    $ perl -MConfig -wle 'print $Config {intsize}; print 1 << 63'
    4
    9223372036854775808
    $
 
$Config {intsize} equals 4, yet we have 64 bit integers.
 
However, $Config {ivsize} should give you the right answer; quoting
"man Config":
 
 
       "ivsize"  
           From perlxv.U:
 
           This variable is the size of an "IV" in bytes.
 
 
 
Abigail

**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**