Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Endemoniada

char in place of int ?

This topic is 5423 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

Hi guys, A lot of times I have a state that can take on a few values (2 to 8 say.) Is it better to use a char (I actually use BYTE) than an int ? Like this: BYTE cur_state; if(cur_state == 0) do some stuff... else if(cur_state == 1) do some stuff... ... ... Is seems like if they are only for if...else tests they would be better, but if they are for arithmetic they might not be as good as ints, like this: BYTE move_offset; int cur_offset; int offset=cur_offset + move_offset; because then I''m mixing types. It may seem like I''m anally micro-optimizing but they are for particles and I have thousands of structs active at any given time so I may as well do it the best way. What do you guys think ? Endo

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
In fact, since modern processors are 32-bit (or more!), its no more efficient, except it may even be more inefficient, to use a byte. Lots of use of bytes rather than words might save you kilobyte or two off the executable, a few kilobytes from RAM usage.. but it could cause you lots of headaches with overflows etc...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!