|
|
| Just another Perl shrine | |
| PerlMonks |
Re: Efficient bit counting with a twist.by quester (Vicar) |
| on Jan 27, 2013 at 07:59 UTC ( [id://1015566]=note: print w/replies, xml ) | Need Help?? |
|
Build a bit mask for the byte that contains the position. Then count the bits in the bytes before the position, and do a bitwise and for the byte that contains the position.
(Update: removed a superfluous pair of parens in the last line.)
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||