+ 2
if float include all digits, for what differents in float ?[double ,...]
😕
8 Respostas
+ 5
Neither float nor double include *all* digits. As float or double have a fixed size this would mean you could encode infinite information in fixed size. Up to now this is thought to be impossible (otherwise everything we know could be coded in just a float or double with severe consequences not only for computer science). So, double and float can only express a finite number of numbers.
double and float are supposed to express real numbers from mathematics. As the body of real numbers is "dense", i.e. there are infinite real numbers between two arbitrary real numbers. (Mind blown? ;-)) There are also infinite real numbers between two floats or two doubles. Consequencially, double and float are an imperfect means to express real numbers as they might not be able to express the real number they are intended to express.
Therefore, this is about having a number format that can represent real numbers closely. As double (double the precision than float hence the name) can express real numbers more precisely and a wider range of them than float it represents real numbers more closely.
This more close representation causes less numeric inaccuracies when using double instead of float when you add, multiply etc which results in more accurate results (important in science and practice).
+ 4
you can also use long double for more larger length range -1.7e4032 to -1.7e4932
+ 3
float occupies four byte in memory can range -3.4e38 to +3.4e38
double occupies 8 byte in memory range from -1.7e308 to +1.7e308
+ 2
float and double both are hold floating point value but double data type has larger length compare to float
+ 2
like 0.222222222
+ 1
?
+ 1
yes
+ 1
tnx