in reply to bit pattern to bit position mapping
You can use unpack to do most of the grunt work
This also obviates the need to determine whether it is a 32-bit or 64-bit quantity. You'll may get a number of zeros at the end of the array. You could clip the unnecessary zeros before splitting into values with:sub b2i { return split //, unpack('b*', @_); }
sub b2i { my $bitstring = unpack('b*', @_); $bitstring =~ s/0+$//; return split //, $bitstring; }
• another intruder with the mooring in the heart of the Perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: bit pattern to bit position mapping
by Anonymous Monk on Nov 19, 2006 at 10:36 UTC | |
by grinder (Bishop) on Nov 19, 2006 at 11:14 UTC | |
by Anonymous Monk on Nov 19, 2006 at 11:31 UTC | |
by grinder (Bishop) on Nov 19, 2006 at 12:51 UTC |