Floating Point Visually Explained

https://fabiensanglard.net/floating_point_visually_explained/index.html

  • Window/offset is a more intuitive way to think about IEE754 floating points compared to the usual exponent/mantissa. I tend to agree, and this mental model makes the fact that you lose precision as the whole number portion of the decimal gets bigger abundantly clear.
  • The window gets 1 byte, and represents any two consecutive powers of two.
  • The offset gets 23 bits, and represents the range of values within the window (and can represent {{< m “2^{23}” >}}) discrete values.
  • To translate a decimal into floating point, find the right window that the whole number portion fits into. Find the offset (one of {{< m “2^{23} = 8388608” >}} possibilities) that matches the remainder as closely as possible.
  • The “default” IEE754 definition (Mantissa, Exponent, Sign): $(-1)^S * 1.M * 2^{(E-127)}$
  • $\pi$ translated to its IEE754 representation, step-by-step: 2020-05-27.11.13.07.png
Edit