On Windows, how can I check whether my Perl installation is 32 or 64 bit?
Just use
log(~0 +1)/log(2)
....
If you want to check if it uses 32-bit integers or 64-bit integers, use the following:
perl -V:ivsize # use Config; say $Config{ivsize}
See also: Answer to "What is the perl equivalent of MAX_INT?"
If you want to check if it uses 32-bit pointers or 64-bit pointers, use the following:
perl -V:ptrsize # use Config; say $Config{ptrsize}
If you want to check if it's a 32-bit program or a 64-bit program, use the following:
perl -V:archname # use Config; say $Config{archname}
x86_64
, it's a 64-bit process.x86
(but not x86_64
), it's a 32-bit process.This value is also included in the output of perl -v
.
Note: You shouldn't be checking use64bitint
or use64bitall
as these indicate what parameters were passed to Configure
rather than provide information about what is actually being used.
Just check the version/build:
perl -v
And I got:
This is perl, v5.8.8 built for msys-64int
Copyright 1987-2006, Larry Wall
...
I'm reading the question to ask if Perl is compiled 64 bit, not if Windows or the CPU is.
Perl can be configured to use varying degrees of 64 bit-ness. You can look this up using the Config module.
To check if Perl is compiled to use 64 bit integers, you can look at the use64bitint
entry in Config.
use Config;
print $Config{use64bitint};
define
indicates yes.
There is also...
use64bitall
meaning perl will be compiled to use all the 64 bit-ness it can, including 64 bit pointers allowing you to access more than 2 gigs of memory.ivsize
indicating how many bytes Perl will use to store an integer, 8 indicates 64 bit.ptrsize
is how many bits Perl will use to store pointers which allows you to use more than 2 gigs of memory per process, 8 indicates 64 bit.Common Config variables and their values can be seen in perl -V
(note the capital V). Their definitions can be found with perldoc Config
.
Note, you can compile Perl to use 64 bit integers regardless of whether your operating system or CPU is 32 or 64 bit. On a 32 bit CPU, Perl will use a type other than "integer" to store numbers, probably "long integer".
log(~0 +1)/log(2)
works because :
So basically this command order perl to say how many bits have its UINT_MAX.
$ perl -e "print log(~0 +1)/log(2)"
32
$ perl -V:archname
archname='MSWin32-x86-multi-thread';