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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:01:15  来源:igfitidea点击:

What exactly does '3.4E +/- 38 (7 digits)' mean?

c++mathnumbers

提问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 floatcan represent is about 3.4e38;
  • the smallest positive value is about 3.4e-38.
  • afloat可以表示的最大正值约为 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, MeEdenotes Mmultiplied by 10 to the E'th power.

这里,MeE表示M乘以 10 的E' 次方。

The

(7 digits)

means that a floatcan 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-38to 3.4E38(positive or negative), with 7 significant digits of precision.

浮点数:范围从3.4E-383.4E38(正或负),精度为 7 位有效数字。

double: Range is from 1.7E-308to 1.7E308(positive or negative), with 15 significant digits of precision.

double:范围从1.7E-3081.7E308(正或负),精度为 15 位有效数字。

They also include 0.

它们还包括 0。

mEeis computer notation for mtimes 10 to the epower.

mEem10 次e幂的计算机符号。