Unofficial Hacker News companion — get notified on comment replies, and more.

Beating Floating Point at Its Own Game: Posit Arithmetic [pdf] (opens external site)

102 points by xenophonf 4 days ago | www.johngustafson.net | 38 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (7)

  1. Worth noting that while these may be smaller than equivalent floats for many values (and indeed, for some applications a 32-bit posit could replace a 64-bit double), they lose precision far more rapidly at larger values, they lack NaN and Infinity entirely, and saturation can silently create enormously incorrect results. Also, attempts at creating hardware implementations have found them far more difficult and bulky than for floats, partly because of all the variable-length shenanigans.

    Still, it's quite nice to see yet another option for representing magnitudes in programming. Given the right domain, these could show many benefits indeed.

    Replies (2)
    1. They have an infinity. It's unsigned and you should probably treat it like a NaN.

      But yeah the tradeoff between precision and range is harsh.

      Replies (2)
      1. Their diagrams represent maxpos as an infinity, but it is simply the limit of their saturating arithmetic, and is just another finite value. If it ever gets into your calculation, you can end up with an incorrect result without realizing maxpos ever happened, and it could be infinitely incorrect.

        At least with IEEE 754 Infinity, it corrupts your entire calculation into Infinity or NaN and then that's obvious in the result. Rounding errors, even compounding ones are also not nearly such a big issue.

        Replies (1)
        1. Maxpos is 0111111, negative maxpos is 1000001. Bit pattern 1000000 used to be infinity but is now "not a real" (I had forgotten the change when I made the previous comment). Combining infinity with NaN means it's even less sneaky than in IEEE, because dividing by it won't give you zero.

          Edit: I guess if you saturate and later divide you might escape maxpos without ever hitting infinity/NaR but that risk doesn't seem significantly worse than standard floating point, just different.

          Replies (1)
          1. Ah wait, you are correct, I misinterpreted the paper. maxpos and infinity are indeed distinct, my bad.
      2. you're supposed to have a mode that lets you turn it into a NaN. Turns out the logic gate for that flag is trivial.
    2. > they lack NaN and Infinity entirely

      These are frequently ditched in AI accelerators anyway, so that's arguably a feature (at least for AI).