08-01-2011 01:18 PM
@smercurio_fc wrote:
I went by the original statement of the problem, which had ones. If you want a more generic solution, that's a simple modification (still with no arrays )
I strongly suspected that there would be a way, but I didn't have it. Thanks you.
08-01-2011 01:26 PM - edited 08-01-2011 01:36 PM
Here is based on what I was saying, but I should've XORed the final step rather than AND.
Try this.
This turns off the bits of interest then toggles them on.
See if it works for all cases.
08-01-2011 01:34 PM
It is simple to merge two values based on a mask. When a bit in the mask is 0, that bit from the 'unmasked' value is chosen, otherwise the bit from 'masked' is chosen.
08-02-2011 08:25 AM
Thx a lot everyone for putting your efforts.