0

why there is separate data types for int and decimal

13th Sep 2016, 9:52 PM
Mohi
Mohi - avatar
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.
13th Sep 2016, 10:36 PM
Cohen Creber
Cohen Creber - avatar
+ 2
The more digits you can have, the greater the memory consumption.
14th Sep 2016, 12:57 PM
Zen
Zen - avatar
+ 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.
13th Sep 2016, 10:52 PM
Avinash Reddy Paduru
Avinash Reddy Paduru - avatar
+ 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/
13th Sep 2016, 11:24 PM
Rodolfo Cangiotti
Rodolfo Cangiotti - avatar
+ 1
thanks
14th Sep 2016, 7:41 AM
Mohi
Mohi - avatar
+ 1
because for usage of memory and resources willbe the better for each case ..
15th Sep 2016, 6:45 PM
hameth
0
hey guys
14th Sep 2016, 1:03 PM
andre
andre - avatar