+ 7
int is the data type that we use for a variable that we want to hold a whole number (e.g. 5, 10); as you know. float is the data type we use for a variable we want to hold a decimal number (e.g. 5.5, 10.35). double is another data type which serves the same purpose as a float; to allow decimals in numbers. The difference being, is that doubles allow for much more precision regarding the number of decimal places that they can hold. For most programs, a float will perform the job sufficiently, and should be used most of the time for memory reasons, as a double will need more allocation (4 vs 8 bytes). If you do need a lot of precision however, say in mathematical equations, then go ahead and opt for a double.
8th Oct 2016, 1:46 AM
Cohen Creber
Cohen Creber - avatar