Jump to content
  • Advertisement


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

graveyard filla

using appropriate data types?

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

high, since i started programming (since november) i have never used the "appropriate" data types for situations. ie, i only use int, float, char, bool. instead of unsigned int, short or long ( "long" and "int" are the exact same according to a book im holding right now?). anyway, i was wondering how important it was to use these. this may be a stupid question, but please dont bash me, i started learning programming in november when i started taking CIS classes at school, and the professors NEVER even told us about long,short,unsigned, etc. they only told us of int, double, etc. well ive learned by now how stupid my teachers are, so im just wondering, how important IS it to use the right data types? i mean, for a simple game like donkey punch adventures (tm), will it be a problem? should i just do it anyway so i get used to it because its good practise? the only difference is a few bytes of wasted memory, correct? thanks for any help!! [edited by - graveyard filla on March 28, 2004 6:18:42 PM]

Share this post

Link to post
Share on other sites
The following are the general instances in which exact type matches matter:
  1. Overflow. Each type has a limit to the values it can represent; if you''re going to perform operations that accumulate a result in a variable, make sure it''s large enough (eg use long rather than short or char when the value will exceed 65536 or 256 respectively for unsigned, and half that for signed).

  2. Storage. If you''re creating a data structure, it''s a good idea to be as precise as possible. No point in wasting space, especially if your structure will/may be transferred over a network.

  3. External libraries and Legacy APIs. These are pieces of code over which you have no control, and which demand exact type matches.

Other than that, it''s really not a big deal.

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.

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!