Hacker News new | ask | show | jobs
by zokier 1607 days ago
> When I started working on this I thought that I might want to switch to "binary coded decimal"[0] to avoid issues with inputs like (0.1 + 0.2 - 0.3).

If you want to go this route, there are standardized decimal floating points, e.g. https://en.wikipedia.org/wiki/Decimal64_floating-point_forma... (or the 128 bit version).

> And is there an implementation I could use?

Afaik Boehms implementation lived only in the Android source tree, i.e. https://android.googlesource.com/platform/packages/apps/Exac... . So to use that you'd need to extract and port them, which might be some effort.

There are all sorts of different approaches for doing calculations on real numbers. I think Johanssons work is particularly impressive in this domain, but I'm not sure if that is much use for a calculator like this: https://fredrikj.net/