C++ “3.4E +/- 38(7 位数字)”究竟是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16029570/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What exactly does '3.4E +/- 38 (7 digits)' mean?
提问by Tez
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 和 double ,范围列为:
float: 3.4E +/- 38 (7 digits)
浮点数:3.4E +/- 38(7 位)
double: 1.7E +/- 308 (15 digits)
双倍:1.7E +/- 308(15 位)
But in layman, what exactly does that mean, and how can I make use of that information?
但对于外行来说,这究竟是什么意思,我该如何利用这些信息?
回答by NPE
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.
- a
float
可以表示的最大正值约为 3.4e38; - 最小的正值约为 3.4e-38。
Similarly, the range of negative values is from -3.4e38 to about -3.4e-38.
类似地,负值的范围是从 -3.4e38 到大约 -3.4e-38。
Here, MeE
denotes M
multiplied by 10 to the E
'th power.
这里,MeE
表示M
乘以 10 的E
' 次方。
The
这
(7 digits)
means that a float
can represent approximately seven significant decimal digits.
意味着 afloat
可以表示大约七位有效的十进制数字。
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.
这些值是近似值的原因是它们在 binary 中是精确的,并且每个二进制数字都有一个小数位数。
回答by Barmar
float: Range is from 3.4E-38
to 3.4E38
(positive or negative), with 7 significant digits of precision.
浮点数:范围从3.4E-38
到3.4E38
(正或负),精度为 7 位有效数字。
double: Range is from 1.7E-308
to 1.7E308
(positive or negative), with 15 significant digits of precision.
double:范围从1.7E-308
到1.7E308
(正或负),精度为 15 位有效数字。
They also include 0.
它们还包括 0。
mEe
is computer notation for m
times 10 to the e
power.
mEe
是m
10 次e
幂的计算机符号。