Left shifts do NOT crop the number corresponding to the length of the original. To get 90, use:
(a<<4) & 0xff
0x59- this is int, and probably is on your platform sizeof(int)==4. Then this is a 0x00000059. A left shift of 4 gives 0x00000590.
Also, create a good habit of using types unsigned intwhen working with bitwise operators if you don't know what you are doing. They have different behaviors in situations similar to right shifts.
source
share