Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Bit fiddling madness

by BrowserUk (Pope)
on Feb 11, 2014 at 16:06 UTC ( #1074431=note: print w/replies, xml ) Need Help??


in reply to Re^2: Bit fiddling madness
in thread Bit fiddling madness

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.)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Bit fiddling madness
by mbethke (Hermit) on Feb 11, 2014 at 16:36 UTC
    built for MSWin32-x86-multi-thread-64int
    The problem only(*) occurs with 32-bit perls:

    Aaargh ... and hadn't even noticed that my laptop's system perl has 64 bit ints even though it's i686 so I'd used it for testingwhat I thought was a 32 bit system m(

    Many thanks everybody, that was the whack I needed!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1074431]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2016-09-28 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (532 votes). Check out past polls.