Jump to content
  • Advertisement
Sign in to follow this  
derek7

BYTE and WORD

This topic is 4943 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 know use WORD to guarantee it is a 16bit. but typedef unsigned short WORD and the unsigned short at any compute and at any OS is guaranteed 16bit? so why use BYTE and WORD?

Share this post


Link to post
Share on other sites
Advertisement
unsigned short isn't guaranteed to be 16-bits, which is why there's the typedef. For compilers which have a differently-sized short you would have a different typedef for WORD.

Share this post


Link to post
Share on other sites
To confuse matters further, word is not always 16 bit, it's a machine word, which on the x86 platform happens to be 16 bit.

For larger project, where you need size specific integrals, I've always prefered keeping a central type header with typedefs for these fixed size ints, using the annotation to clearly specify their resolution. For instance, int8, uint8, int16, and so on.

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!