lyeoh has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
Given an unsigned 32 bit value (set initially to zero) and a 32 bit mask.
How would I increment just the masked bits through all their possible combinations, without trying the entire 32 bit range.
e.g. given a mask of 0x0f000007
it'll go through
0x00000000 0x00000001 .. 0x00000007
then
0x01000000 0x01000001 0x01000002 .. 0x01000007 .. 0x02000000 0x02000001 ..
and so on till
0x0F000007
Is there a good and quick way of doing this in perl?
Thanks!
20051110 Janitored by Corion: Removed PRE tags, put in proper formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Incrementing only the masked bits (sure)
by tye (Sage) on Nov 10, 2005 at 07:30 UTC | |
by GrandFather (Saint) on Nov 10, 2005 at 19:48 UTC | |
|
Re: Incrementing only the masked bits
by Roy Johnson (Monsignor) on Nov 10, 2005 at 16:42 UTC | |
by tye (Sage) on Nov 10, 2005 at 20:18 UTC | |
|
Re: Incrementing only the masked bits
by gaal (Parson) on Nov 10, 2005 at 07:27 UTC |