in reply to first 5 bits and last 3 bits
my $byte = 129; # 0b10000001 = 129 my $most_significant_5 = $byte >> 3; # 0b10000 = 16 my $least_significant_3 = $byte & 0x7; # 0b 001 = 1
How did I arrive at that? Basically, you want to either
is a simplification of ---------------------------------------------------- $byte >> 3 ( $byte & 0xFF ) >> 3 or ( $byte >> 3 ) & 0x1F $byte & 0x7 ( $byte & 0x7 ) >> 0 or ( $byte >> 0 ) & 0x7
Notes;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: first 5 bits and last 3 bits
by pashanoid (Scribe) on Jul 27, 2011 at 06:15 UTC |