Hacker news

  • Top
  • New
  • Past
  • Ask
  • Show
  • Jobs

More Floating Point Alternatives (https://wizardzines.com)

14 points by vismit2000 2 days ago | 11 comments | View on ycombinator

AlotOfReading about 2 hours ago |

Usually, if you know enough about your algorithms to select an appropriate float alternative, you also know enough to fix your float code and that's what you should actually do.

That said, some of these aren't alternatives. Symbolic computation is a different thing entirely. Interval arithmetic can be built atop floats (e.g. IEEE-1788) and has its own zoo of unintuitive behaviors. BCD is better called a historical artifact than an alternative these days.

It's really just rationals and decimal floats in this list, which probably don't solve the issues you have if you're considering float alternatives.

ashton314 about 1 hour ago |

Also of interest: Herbie analyzes your math expressions and helps you figure out where FP error accumulates. https://herbie.uwplse.org/demo/

We use floats as a trade-off between speed and accuracy. IEEE 754 is a very reasonable trade-off for a wide range of applications, but if you can figure out where you need to trade speed to get more accuracy with e.g. one of the methods mentioned here, Herbie's gotcha covered.

I remember seeing some research about switching between formats, but I don't have anything to cite right now.

MiroslavPokorny 2 days ago |

Strange the most obvious - fixed point numbers is not mentioned.

klodolph about 2 hours ago |

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.

schiffern 2 days ago |

None of the base 10 formats, but the hobby calculation language Frink supports exact rational fractions, arbitrary width bigints (not pictured), intervals arithmetic, and symbolic expressions.

https://frinklang.org/fsp/frink.fsp?fromVal=new+interval%5B-...