Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Strange! But:% perl -le 'print vec(0x0, 5,1)' 1
Huh? And:% perl -le 'print vec(0x0, 6,1)' 0
I thought "" would be the same as 0 in memory -- all 0 bits! So I naturally looked up the perldoc on vec(), and tried out this:% perl -le 'print vec("", 5,1)' 0
What gives? Can anyone explain to me why 0 has two non-zero bits in it? And is the only real solution to my bug to just use bit operations rather than vec() (ugh!) Thanks!% perl -le '@bits = split(//, unpack("b*", 0x0)); print "@bits"' 0 0 0 0 1 1 0 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: bits, vec(), zero, and unpack weirdness
by bart (Canon) on May 27, 2004 at 21:36 UTC | |
|
Re: bits, vec(), zero, and unpack weirdness
by duff (Parson) on May 27, 2004 at 21:35 UTC | |
|
Re: bits, vec(), zero, and unpack weirdness
by Roy Johnson (Monsignor) on May 27, 2004 at 21:37 UTC |