Author Topic: Determining the correct Data Types  (Read 7326 times)

pghtech

  • Guest
Determining the correct Data Types
« on: August 09, 2006, 03:09:06 pm »
This is such a primative question for most of you programmers....but as much as I have read about C++ and attempting to imply in my programs, I keep coming across a dilemma.

I know there is a number of different data types, with a number of different categories.  what i mean is similar types such as int, short int, long it / float, double, long double...ect.

Well I seems when I am trying to figure out what to make a variable in my program, I am narrow focused on just a few types (strings, ints and floats).  But when I read books and other literature, even for their most basic programs, and most basic variables, they will be very specific with making them uint and long int....ect. 

Is there any advice that can be given to me, to help me figure out how specific I need to go with a variable (Besides the obvious of if it is a number vs. a string).  I mean, when I should narrow it to a short int, rather than just an int - just because and int will carry it.

Any advice?

PDEE

  • Guest
Re: Determining the correct Data Types
« Reply #1 on: August 09, 2006, 03:23:18 pm »
It is not a general programming forum

Read this:

http://en.wikibooks.org/wiki/C++_Programming/Data_Types_Reference

Took me ten seconds to find on google
« Last Edit: August 09, 2006, 03:27:15 pm by PDEE »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Determining the correct Data Types
« Reply #2 on: August 09, 2006, 04:05:49 pm »
@pghtech: please read the board description, specifically the part that says "This is NOT a general programming board".

Thank you.
Be patient!
This bug will be fixed soon...

pghtech

  • Guest
Re: Determining the correct Data Types
« Reply #3 on: August 09, 2006, 05:28:08 pm »
Sorry....

I didn't see that...but now that I have went back and read every single forum description....you have none on programming...sorry for the inconvenience.


Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Determining the correct Data Types
« Reply #4 on: August 09, 2006, 05:38:05 pm »
These boards are for CB related stuff, not just for general programming techniques etc.

To come back to your question :
  - short, long : better sicne an int can be 2 or 4 bytes
  - unsigned or not : 2 approaches : all signed ->no need for casting (otherwise at conversions between  signed/unsigned), or closely fitting your model : if something can't be negative then your code reflects that when you use an unsigned.


Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Determining the correct Data Types
« Reply #5 on: August 09, 2006, 08:02:07 pm »
I didn't see that...but now that I have went back and read every single forum description....you have none on programming...sorry for the inconvenience.
Excuse me, you have already been told yesterday, not only by me, but also by Game Ender and MortenMacFly. You replied to it, too.
Seriously, what is there not to understand about it?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."