0
why there is separate data types for int and decimal
7 Respuestas
+ 3
Because sometimes you want to work with just whole numbers rather than decimals. What if you were counting something in a program? Why waste memory declaring a float or a double when you could just declare an int, as counting only really goes in whole numbers only.
+ 2
The more digits you can have, the greater the memory consumption.
+ 1
You don't need to be too accurate all the time. int always displays a rounded value, where as float or double displays the precision too. You can argue that we can take rounded values with float by keeping the int values in that and also that float takes same memory as int. But remember, floating point arithmetic takes more time than int, because of its implementation with IEEE 754 with sign, exponent and fraction. You will be wasting processors time. Modulo operation is also not possible with float.
+ 1
Because integer numbers and decimal, that is floating point numbers, are represented into the digital domain by different ways. Here is a brief explanation: http://www.dummies.com/programming/c/the-real-difference-between-integers-and-floating-point-values/
+ 1
thanks
+ 1
because for usage of memory and resources willbe the better for each case ..
0
hey guys