You want to shift by 6*4 = 24 bits, not just 6 bits. Each '0' in the hex printf represents 4 bits.
unsigned int part_1b = part_1 >> 24;
^^
Question
I have a variable (unsigned int) part_1
.
If I do this:
NSLog(@"%u %08x", part_1, part_1);
(print unsigned value, and hex value) it outputs:
2063597568 7b000000
(only first two will have values).
I want to convert this to
0000007b
So i've tried doing
unsigned int part_1b = part_1 >> 6
(and lots of variations)
But this outputs:
32243712 01ec0000
Where am i going wrong?
Solution
You want to shift by 6*4 = 24 bits, not just 6 bits. Each '0' in the hex printf represents 4 bits.
unsigned int part_1b = part_1 >> 24;
^^