Re: Extracting bits out of huge numbers
- From: Ben Morrow <ben@xxxxxxxxxxxx>
- Date: Thu, 31 Jul 2008 15:15:53 +0100
Quoth bugbear <bugbear@xxxxxxxxxxxxxxxxxxxxxxxxx>:
hofer wrote:
>>
>>Example Bits 16 bis 12 should result in 0b00001 == 0x1 == 1
>> Bits 17 bis 12 should result in 0b100001 == 0x21 == 33
what do you mean by
"Bits 16 bis 12"
and
"Bit 17s bis 12"
what is "bis" ?
'To' in English, 'through' or 'thru' in American. So, the OP wishes to
look at only the bits from bit 16 to bit 12; something like
my $num = ...;
my $mask = 0;
$mask |= 1<<$_ for 12..16;
$num &= $mask;
$num >>= 12;
would do what he wants, but slowly, and with small(ish) integers only.
Ben
--
And if you wanna make sense / Whatcha looking at me for? (Fiona Apple)
* ben@xxxxxxxxxxxx *
.
- References:
- Extracting bits out of huge numbers
- From: hofer
- Re: Extracting bits out of huge numbers
- From: bugbear
- Re: Extracting bits out of huge numbers
- From: hofer
- Re: Extracting bits out of huge numbers
- From: bugbear
- Extracting bits out of huge numbers
- Prev by Date: Re: Logging with Log::StdLog from within a package
- Next by Date: Re: questions on XML::Simple
- Previous by thread: Re: Extracting bits out of huge numbers
- Next by thread: FAQ 3.6 How do I profile my Perl programs?
- Index(es):