I am running on AIX and I guess you may be on Windows ? I think your byte order must be the other way round than mine. When you get up to 253..256 does the last value go 7,7,7,0
apart from the binary bytes being reversed the rest works as expected for me on 'doze (NT4)
253 11111101000000000000000000000000 7 254 11111110000000000000000000000000 7 255 11111111000000000000000000000000 7 256 00000000000000010000000000000000 0
If you replace the I* in the pack with N (force byte order we want and the * was never really required) I think you may see something nicer. This version works on box *nix and *dose for me
perl -le'print join "\t", $_, (unpack "B*", pack "N", $_), ($_ & 0xFF) + >>5 for (0..256)'
Cheers,
R.
In reply to Re^4: calculating the 3 MSBs from an integer
by Random_Walk
in thread calculating the 3 MSBs from an integer
by insaniac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |