‹ BackHN Continuity

Thread

More floating point alternatives

53 points · 51 comments · vismit2000

  1. klodolph · · focus · HN ↗
    Worth mentioning is storing the logarithm of the number.

    Seen it used in a couple places. Logarithmic depth buffer is one. Yamaha DX7 is another.

    1. mtklein · · focus · HN ↗
      That's kind of exactly what floats are. You store the log2 of the number, a bit for its sign, and in what remaining bits you have left some fixed-point scaling between adjacent powers.
      1. mdspan · · focus · HN ↗
        I think they mean storing just an exponent instead of an exponent + mantissa. Makes multiplication much easier to implement.
      2. em3rgent0rdr · · focus · HN ↗
        No, that is not what floats are. A logarithmic number system literally just stores the logarithm of a number (and a sign bit) and manipulates it as a logarithm. The significand is 1, always. So multiplication & division are simply addition & subtraction, respectively. But this simplification for multiplication, division, roots, and powers is counterbalanced by more complex addition and subtraction.[1]

        [1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Logarithmic_number_system" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Logarithmic_number_system

      3. pkaye · · focus · HN ↗
        Floats are actually rational numbers with denominators of power of 2.

        <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Dyadic_rational#In_computing" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Dyadic_rational#In_computing

    2. Archit3ch · · focus · HN ↗
      You can also use this in analog hardware! :D

      <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Translinear_circuit" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Translinear_circuit

    3. vrighter · · focus · HN ↗
      how do you do FMAs then? You&#x27;re making one operation cheaper, but making the other one expensive.
      1. klodolph · · focus · HN ↗
        “You’re making one operation cheaper, but making the other one more expensive” is the wrong way around. Say it this way: “You’re making one operation more expensive, but the other one cheaper.”
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.