problems with bit shifting
i have a number, in this case it is 0x01010052, which represents a 3 part code for identifying an object. i have constructed it in the following fasion:
(0x01 << 24) | (0x01 << 16) | (0x0052)
the number, as received by my function, is 0x01010052, as it should be.
i am trying to extract the second part of the code, and i do so with (code >> 16) & 0xFF
the result of this, however, is 0x00000004, which is not correct. Here is what i have determined through the debugger:
typeID 0x01010052
typeID >> 4 0x00101005
typeID >> 8 0x00010100
typeID >> 12 0x00000040
typeID >> 16 0x00000004
These last two do not seem right, they should be 0x00001010 and 0x00000101, respectively, shouldn't they be.
if anyone can help me with this, it would be greatly appreciated.
Thanks
personwholives
typeID >> 4 0x00101005 -> ok
typeID >> 8 0x00010100 -> ok
typeID >> 12 0x00000040-> 0x12!!!
typeID >> 16 0x00000004-> 0x16!!!
Don't confuse dez and hex [wink].
typeId >> 0x10 == typeId >> 16 == (typeId & 0xFF0000) >> 16
typeID >> 8 0x00010100 -> ok
typeID >> 12 0x00000040-> 0x12!!!
typeID >> 16 0x00000004-> 0x16!!!
Don't confuse dez and hex [wink].
typeId >> 0x10 == typeId >> 16 == (typeId & 0xFF0000) >> 16
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement