Archived

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

32bit data == increased speed?

This topic is 5181 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 started working on the two classes for my isometric tile game which I think will be the most important and most frequently used. (A class to represent Characters and a class to represent each square unit of the map) I notice that both of these classes are going to need a lot of member variables that will hold numbers that will never exceed 255. So it seems kind of ridiculous to hold all of these numbers in 32 bit data types. However, I''ve seen many people go out of their way to use 32 bit variables because, supposedly, 32 bit processors can use them much faster. I understand that the windows BOOL is 32 bits. So, will the speed increase from using 32 bit variables outweigh the fact that my objects are 4 times as big as they need to be?

Share this post


Link to post
Share on other sites
You''re micro-optimizing. Use whatever data type works best: the speed difference is going to be minimal. Your compiler may pad some of the data for you anyways to make it work faster.

Share this post


Link to post
Share on other sites
Or, even better yet... why not define a type, like...

//typedef unsigned long MapIDType;
typedef unsigned char MapIDType;

MapIDType MyMap[256*256];


This way, you can easily compare the speed between both and leave whichever is faster, and you can even check other types, like short''s and stuff. We can''t tell you which will work better, and trying multiple types isn''t difficult, so you might as well do it with a typedef or #define and check all the possibilities and use whichever is faster in practice, not just in theory .

Share this post


Link to post
Share on other sites