‹ BackHN Continuity

Thread

Subnormal floating-point numbers are expensive on Intel processors

69 points · 54 comments · zdw

  1. rf15 · · focus · HN ↗
    ...Is this running extra micro code to fix some hardware bug/unreliability? How can this happen? Doesn't look like a normal design decision.
    1. Sharlin · · focus · HN ↗
      Subnormal numbers have a different, basically fixed-point, representation. They exist in order to bridge the large (relatively speaking; indeed "infinite" in a sense) gap between the least positive normal number, zero, and the greatest negative normal number, caused by the usual significand-exponent representation.

      Most "mundane" uses of floating point have no need for subnormal numbers, and results that underflow could just be flushed to zero. But they’re sometimes important in scientific computing to ensure sufficient smoothness around zero, avoiding precision issues.

      1. jwmerrill · · focus · HN ↗
        One nice thing that subnormals get you is the property that if x-y == 0 then x == y. If you want to guard against division by 0, and your denominator is a difference of two terms, it’s nice to be able to check equality of those terms and know that if they are not equal, then their difference will not be 0.

        More generally, subnormals are needed for Sterbenz Lemma to hold everywhere: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Sterbenz_lemma" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Sterbenz_lemma

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.