Hello everyone,
I'm desperatly trying to do the following:
I have an int which I use to hold 4 pairs of bits. I want to be able to set the pairs of bits within the int like this:
setpair($stuff, $i, $bits)
where $stuff is an int,
$i is an index (0, 1, 2 or 3)
and $bits is a two bit value: 00, 01, 10, or 11.
For example:
$stuff = 10 01 10 01
$i = 2
$bits = 10
setpair($stuff, $i, $bits) would set $stuff to 10 10 10 01 (the second pair of bits starting from 0 is set to the value of $bits).
I tried different things but I'm not getting the results I want. Any help would be appreciated!
Thanks,
Matt.