+ 3
Whats the point of so many data types?
why do we need so many different data types like int, float, double etc AND modifiers like short long etc? can't we have just one that does all the work?
3 Antworten
+ 15
Data types are required so that you know what "kind" of data your variable holds, or can hold. If you (and compiler, and runtime) know this information in advance, you can save a hell lot of runtime issues at compile time only, and also for utilizing the minimum memory space.
+ 3
thank you!
+ 1
By the time c and c++ were created, computers weren't that powerful enough to always use the biggest datatypes. You had to choose the datatype wisely to save ram, make your computer working faster and so on.
Today you can choose almost freely what datatype you prefer. As long as the problem you're solving is no big deal, a complex game or you are working with a very limited micro controller. I'm, for example, using int for numbers most of time:)