0

I dont understand why I should use the diferend types int double and float and not juast one general

17th Aug 2016, 10:03 PM
maxilinn
maxilinn - avatar
3 Réponses
+ 7
For performance reasons. When you declare a variable, e.i. int Variable, the compiler puts aside memory for that variable and what it will store. Now the amount of memory put aside is dependant on the declaration. A char uses less memory that an int, an int uses less memory than a float, and a float uses less memory than a double. So if you're going to have single digit number, no decimal value to it, would it really make sense to declare it a double and put aside extra memory you dont need. Or would it make more sense to just use the memory you need and declare it an int.
17th Aug 2016, 10:22 PM
Donovan
Donovan - avatar
0
just for allocation of memory
18th Aug 2016, 1:21 AM
Aman Ankur
Aman Ankur - avatar
0
good....really good answer I like it
18th Aug 2016, 2:32 AM
Dipankar Mondal
Dipankar Mondal - avatar