Today I Learned

Posted on Apr 13, 2025
tl;dr: and hope I don't forget tomorrow :(

20250413

python floating point sucks (?): https://docs.python.org/3/tutorial/floatingpoint.html

  • commonly known as python floats, according to this article:
Since at least 2000, almost all machines use IEEE 754 binary floating-point arithmetic, and almost all platforms map Python floats to IEEE 754 binary64 “double precision” values.
  • IEEE 754 binary64 values have 53 bits of precision, which is represented as J/2**N
    • base/radix: 2 or 10
    • precision
    • exponent range from emin to emax where emin = 1-emax
  • memomry layout: https://en.wikipedia.org/wiki/IEEE_754
    • 53 digits, exponent is in range [-1022, 1023], which takes 10 bits, in total 63 bits
    • with one additional sign bit