lennxa

Android Calculator App

Link | #tech, #story

The intriguing story of how the android calculator app was built by Hans-J. Boehm. The problem comes to floating point issues. BigNum solves the problem for integers and also rational fractions (numerator and denominator as BigNum), but the problem remains for irrationals (2,π). Recursive Real Arithmetic (RRA) solves the irrationals - but at a cost.

Given an expression and how precise you want the answer, RRA gives you an answer at least that precise.

...

When users type "1-1", the answer is 0, so you want to show "0".

But RRA will only tell you "1-1 is within a rounding error of 0.0000000000000"

The final implementation is a compromise:

You only need RRA when rational numbers aren't enough. Use it when numbers like π or √2 come into play, use rationals otherwise

...

All the digits shown on the screen are always correct. And they almost never show more digits than necessary.

...

But what Boehm and co came up with is 100% correct, and gets 99% of the way to the perfect UX at only 1% of the implementation complexity.

Tradeoffs between implementation complexity and features is a delicate consideration. This reflects both the diminishing returns on pursuing perfection and opportunity cost of development resources.

#links #story #tech