Jump to content
  • Advertisement
Sign in to follow this  
personwholives

problems with bit shifting

This topic is 5409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try (code & 0xFF0000) >> 16;

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!