Quick question regardin bit shifting
im trying to shift two bytes of "binary" to OR them together and allow a carry from byte1 to be placed into byte2.
at the moment, im trying to shift byte1 by 7 places to the RIGHT and byte2 by 1 place to the LEFT.
i need to use the logical shift and not the arithmetic one so could someone look at the couple of lines of code below to tell me why, when i or together two bytes i get the wrong answer.
Code:
firstbyte[0] = (squashdum[1] >>= 7);
Code:
secondbyte[0] = squashdum[2] <<= 1;
Code:
result[1] = (firstbyte[0] | secondbyte[0]);
imagine first byte is 01100101
and second byte is 10000111
the result should be "00001110". = e0
but actually comes through as "00001111"? = f0
thanks