+ 1

Why are there multiple variable types? Why couldn't there just be one variable type that holds any number?

1st Jun 2017, 11:29 PM
Riley Nielsen
Riley Nielsen - avatar
4 ответов
+ 10
I imagine if every variable datatype had the same size as the largest datatype (in order for a single, universal datatype which can store all kinds of variables to exist), the program created will be bloat. Furthermore, the load dumped onto the compiler when it needs to identify​ if variables are used correctly for calculations (e.g. Can't add string to int) would increase exponentially.
2nd Jun 2017, 2:50 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
Do you put your dirty shocks together with your clean shocks in the same location?
1st Jun 2017, 11:41 PM
Ghauth Christians
Ghauth Christians - avatar
+ 2
Data types have different sizes in memory, they are also treated differently. Floating point numbers use different registers than regular numbers, along with different instruction sets
2nd Jun 2017, 1:32 AM
aklex
aklex - avatar