built for MSWin32-x86-multi-thread-64int
The problem only(*) occurs with 32-bit perls:
C:\test>type CIDRtest.pl #! perl -slw use strict; use integer; for my $n ( 0 .. 31 ) { my $addr = (1 << $n) + 1; printf "\r%u", $addr; my $nbits = 32; while( 1 ) { my $bit = ( $addr & 0x80000000 ) >> 31; die "$addr -> $bit" if $bit != 0 and $bit != 1; $addr <<= 1; last unless --$nbits; } } C:\test>CIDRtest.pl 2147483649 C:\test>\perl32\bin\perl.exe CIDRtest.pl -2147483648 -> -1 at CIDRtest.pl line 11. 2
(*Or 64-bit perls, but with much higher numbers.)
In reply to Re^3: Bit fiddling madness
by BrowserUk
in thread Bit fiddling madness
by mbethke
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |