news.west.cox.net said:
I do not know how many bits can go in a perl number.
You should do some simple tests to find the number of bits
for the particular version of perl you are using.
linux% cat test.pl
$num = 24465973248;
$bit18 = 131072;
printf "%15.2f = 0x%09x = 0xb%036b\n",$_,$_,$_ for
($num,$bit18,$num&$bit18);
linux% perl test.pl
24465973248.00 = 0x0ffffffff = 0xb000011111111111111111111111111111111
131072.00 = 0x000020000 = 0xb000000000000000000100000000000000000
131072.00 = 0x000020000 = 0xb000000000000000000100000000000000000
Now try it on a system using a CPU that is wider than 32 bits.
tops20@ type test.pl
$num = 24465973248;
$bit18 = 131072;
for ($num, $bit18, $num&$bit18) {
printf "%15.2f = 0x%09x = 0xb%036b\n",$_,$_,$_ ;
}
tops20@ perl test.pl
24465973248.00 = 0x5b2492000 = 0xb(printf: 'b'?)
131072.00 = 0x000020000 = 0xb(printf: 'b'?)
0.00 = 0x000000000 = 0xb(printf: 'b'?)
-Joe