[Israel.pm] perl on 64-bit machine

Gaal Yahas gaal at forum2.org
Thu Mar 10 10:08:48 PST 2005

Madani, Srikanth, VF-DE wrote:

> >   perl -le 'print "This is a " . 3.2*length(~0) . " bit machine."'
>I ran the above line, and got:
>	This is a 32 bit machine.
>And what does that mean? That the address bus of my processor is 32 bits
>That no process can access more than 2^32-1 memory locations?
>(It's been a long time since my Computer Architecture classes)
It means the native int (or what the compiler thought was a native int) 
is 32 bits wide.

See perlnumber and perlop.

(The "length" up there is just a silly obfuscation. On my machine, ~0, 
the one's complement of zero, is 2^32-1. On a 64-bit machine, it is 
(likely) to be 2^64-1, or 18446744065119617025. length returns the 
length of a string, e.g., the number of digits in it, e.g., an 
appoximation of the base-10 log of the number; though not a very good 
one, it is good enough for our purposes.)

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list