Code::Blocks Forums
User forums => General (but related to Code::Blocks) => Topic started by: pghtech 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?
-
It is not a general programming forum
Read this:
http://en.wikibooks.org/wiki/C++_Programming/Data_Types_Reference (http://en.wikibooks.org/wiki/C++_Programming/Data_Types_Reference)
Took me ten seconds to find on google
-
@pghtech: please read the board description, specifically the part that says "This is NOT a general programming board".
Thank you.
-
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.
-
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.
-
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?