简体   繁体   English

了解浮点精度

[英]Understanding floating point precision

Is it the case that: 是这样的情况:

  1. Representable floating point values are densest in the real number line near zero? 可表示的浮点值在零附近的实数行中最密集?
  2. Representable floating point values grow sparser (exponentially?) as the number line moves away from zero? 当数字线偏离零时,可表示的浮点值会变稀疏(指数?)?
  3. If the above two are true, does that mean there is less precision farther from zero? 如果以上两个都是真的,那是否意味着距离零更远的精度更低

Overall question: Does precision in some way refer to or depend on the density of numbers you can represent (accurately)? 总体问题:精确度在某种程度上是指或可以依赖于您可以表示的数字密度 (准确)吗?

The term precision usually refers to the number of significant digits (bits) in the represented value. 术语精度通常是指所表示的值中的有效位数(位)。 So precision varies with the number of bits (or digits) in the mantissa of representation. 因此精度随着表示的尾数中的位数(或数字)而变化。 Distance from the origin has no role. 与原点的距离没有任何作用。

What you say is true about the density of floats on the real line. 你说的关于实线上浮子密度的真实情况。 But in this case the right term is accuracy, not precision. 但在这种情况下,正确的术语是准确性,而不是精确性。 FP numbers of small magnitude are far more accurate that larger ones. 小幅度的FP数字比较大的FP数字准确得多。 This contrasts with integers, which have uniform accuracy over their ranges. 这与整数形成对比,整数在其范围内具有统一的精度。

I highly recommend the paper What Every Computer Scientist Should Know About Floating Point Arithmetic , which covers this and much more. 强烈推荐“ 每个计算机科学家应该知道的关于浮点算术的文章” ,其中涵盖了这一点以及更多内容。

Floating point numbers are basically stored in scientific notation. 浮点数基本上以科学计数法存储。 As long as they are normalized, they consistently have the same number of significant figures, no matter where you are on the number line. 只要它们被标准化,无论您在数字线上的哪个位置,它们始终具有相同数量的有效数字。

If you consider density linearly, then the floating point numbers get exponentially more dense as you get closer to 0. 如果您线性地考虑密度,那么当您接近0时,浮点数会呈指数级增加。

As you get extremely closed to 0, and the exponent reaches its lowest point, the floating point numbers become denormalized. 当你非常接近0并且指数达到最低点时,浮点数变为非规范化。 At this point, they have 1 extra significant figure and are thus more precise. 在这一点上,他们有一个额外的重要数字,因此更精确。

Answers: 回答:

  1. Representable floating point values are densest in the real number line near zero? 可表示的浮点值在零附近的实数行中最密集? Yes
  2. Representable floating point values grow sparser (exponentially? Yes ) as the number line moves away from zero? 当数字线偏离零时,可表示的浮点值变得更稀疏(指数式? )? Yes
  3. If the above two are true, does that mean there is less precision farther from zero? 如果以上两个都是真的,那是否意味着距离零更远的精度更低 Yes

Overall question: Does precision in some way refer to or depend on the density of numbers you can represent (accurately)? 总体问题:精确度在某种程度上是指或可以依赖于您可以表示的数字密度 (准确)吗?

See https://stackoverflow.com/a/24179424 请参阅https://stackoverflow.com/a/24179424

I also recommend What Every Computer Scientist Should Know About Floating Point Arithmetic 我还推荐每个计算机科学家应该知道的关于浮点运算的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM