‹ BackHN Continuity

Thread

Subnormal floating-point numbers are expensive on Intel processors

69 points · 54 comments · zdw

  1. gwbas1c · · focus · HN ↗
    I'm still trying to understand what a subnormal number is; IE, I'm looking for the TLDR so I know just enough to know if I'm using them and need to learn more.

    Unfortunately, the Wikipedia article, while probably being accurate, doesn't give a clear and concise answer.

    IE, is 0.0001 a subnormal? Or is it 0.000000000000000000001?

    1. dgrunwald · · focus · HN ↗
      For 32-bit floats, subnormals are the numbers closer to 0 than 2**(-126) == 0.0000000000000000000000000000000000000117549. For 64-bit doubles, it's 2**(-1022), a number starting with 308 decimal zeroes.
      1. fuzzfactor · · focus · HN ↗
        What about 8-bit and 16-bit?
        1. adrian_b · · focus · HN ↗
          It should be noted that subnormals have appeared for the first time in standards a decade before Intel 8087 (the ancestor of the IEEE standard), in the standards for digital telephony, and that happened in a certain form of FP8.

          When telephony transitioned from analog voice transmission to digital, the PCM (pulse-code modulation) encoded audio signal used 8-bit samples, which were a form of 8-bit floating-point numbers (with American and European encoding variants: mu-law and A-law). The use of a floating-point format enabled the 8-bit samples to have a dynamic range as big as for a 12-bit or 13-bit fixed-point encoding.

          Subnormals where used in digital telephony, because otherwise the errors around zero would have been so great that the voice audio would not have been intelligible.

          In general, in smaller floating-point formats the use of subnormals is even more important than in bigger formats, in order to avoid the loss of precision around zero.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.