Search CTRL + K

Floating Point

浮点是将实数在计算机中表示、存储的一种方式,由于进制差异只能存储近似值,一般用于存储小数。

IEEE 754 标准

1985 年提出的 IEEE 754 标准规定了浮点数的表示方式,以 32 位浮点数举例:

通过公式可以计算浮点数:

FP=(1)S1.M2E127

  • S 作为符号
  • E 划分数据窗口(Window),[20,21],[21,22],...,[2127,2128]
  • M 将窗口划分为 223=8388608 个点,每个点都是浮点数可以精确表示的数

可以看到,当 E 越大,精度约低。


Wikipedia

In computing, floating-point arithmetic (FP) is arithmetic that represents real numbers approximately, using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base. The term floating point refers to the fact that the number's radix point can "float" anywhere to the left, right, or between the significant digits of the number. This position is indicated by the exponent, so floating point can be considered a form of scientific notation. [2]


  1. https://fabiensanglard.net/floating_point_visually_explained/ ↩︎

  2. https://en.wikipedia.org/wiki/Floating-point_arithmetic ↩︎