+ 4

What does float and double mean? What would they be used for?

26th Sep 2016, 1:27 PM
Drew
Drew - avatar
8 Answers
+ 11
What does float and double mean? What would they be used for? Both are real numbers along with the variable type decimal. float: a variable type that represents single-precision floating-point numbers that are 32 bits in size and have 7 digits of precision. double: a variable type that represents double-precision floating-point numbers. double require twice the memory(64bits) and ~twice the precision(15-16) of float variables. This allows double variables to store larger numbers with greater precision(the numbers to the right of the decimal point.) compared to float. Want a more precise real number use double over float. Want an even more precise real number, use decimal over both double and float. Floating-point numbers (double&float) are not always 100% correct since their precision ends at a certain point. They can still be useful in certain scenario where you need a rough amount that's close to the exact amount. Say you want to take the temperature outside and only want to know if it's 82.3 degrees, when it's actually 82.3657654895647568 degrees. Then float or double would be good for this example because you don't need or want to know the exact temperature. However, let's say we're talking about monetary amounts, double and float would be less suited for this since we want a precise  amount. To most this would be extreme but today companies make big money off taking a hundredth or a thousandth of a percent per penny per transaction. Considering the unimaginable amount of money and transactions mega companies perform, knowing the exact amount is huge business for them. Finally, when using a floating-point variable, double is normally preferred over float due to it's better accuracy.
27th Sep 2016, 4:38 AM
Alex Wiggins
Alex Wiggins - avatar
+ 3
float is a decimal number. 1.473637 Double can hold more decimals than float. And takes more memory. What haytham said with true or false applies to boolean, or bool.
26th Sep 2016, 2:10 PM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
+ 2
you're welcome
26th Sep 2016, 1:34 PM
haytham rmmal
haytham rmmal - avatar
+ 2
float and double are nearly seems to be same but double allows larger numbers to store the numbers in real form (ex 1.7076)
29th Oct 2016, 10:17 AM
Nishan
Nishan - avatar
+ 1
Thx
26th Sep 2016, 1:32 PM
Drew
Drew - avatar
0
thanks andreas sorry drew
26th Sep 2016, 2:13 PM
haytham rmmal
haytham rmmal - avatar
- 2
double =3:4 2:4 x:y ........
26th Sep 2016, 1:30 PM
haytham rmmal
haytham rmmal - avatar
- 6
float = true or false
26th Sep 2016, 1:30 PM
haytham rmmal
haytham rmmal - avatar