问题
I'm trying to understand the range of data types. For non-floating point numbers it's easy enough, but then for float and double the ranges are listed as:
float: 3.4E +/- 38 (7 digits)
double: 1.7E +/- 308 (15 digits)
But in layman, what exactly does that mean, and how can I make use of that information?
回答1:
The
3.4E +/- 38
means that:
- the largest positive value that a
float
can represent is about 3.4e38; - the smallest positive value is about 3.4e-38.
Similarly, the range of negative values is from -3.4e38 to about -3.4e-38.
Here, MeE
denotes M
multiplied by 10 to the E
'th power.
The
(7 digits)
means that a float
can represent approximately seven significant decimal digits.
The reason of these values are approximate is that they are exact in binary, and there's a fractional number of decimal digits for each binary digits.
回答2:
float: Range is from 3.4E-38
to 3.4E38
(positive or negative), with 7 significant digits of precision.
double: Range is from 1.7E-308
to 1.7E308
(positive or negative), with 15 significant digits of precision.
They also include 0.
mEe
is computer notation for m
times 10 to the e
power.
来源:https://stackoverflow.com/questions/16029570/what-exactly-does-3-4e-38-7-digits-mean