The posted code (by the OP) doesn't work because you're shifting the wrong way. If you shift 00000001 right by any number of bits this will become zero. To get 10000000 from 00000001 you need to shift it LEFT by 7 bits (operator <<), not right (>>).