< Previous | Contents | Next >
You have many choices when it comes to the fundamental types. So how do you know which type to use? Well, if you need an integer type, you’re probably best off using int. That’s because int is generally implemented so that it occupies an amount of memory that is most efficiently handled by the computer. If you need to represent integer values greater than the maximum int or values that will never be negative, feel free to use an unsigned int.
If you’re tight on memory, you can use a type that requires less storage. However, on most computers, memory shouldn’t be much of an issue. (Pro- gramming on game consoles or mobile devices is another story.)
Finally, if you need a floating point number, you’re probably best off using float, which again is likely to be implemented so that it occupies an amount of memory that is most efficiently handled by the computer.