Understanding floating point precision

前端 未结 3 1675
情话喂你
情话喂你 2021-01-06 17:45

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 spars
3条回答
  •  时光说笑
    2021-01-06 18:07

    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. 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.

提交回复
热议问题