Skip to content

Comment on More Intuitive Calculator Arithmetic (2018)

Comments

It took a while for us to settle on the idea of using rationals with limited-sized integers for the numerator and denominator and falling back to binary floating point when we have to. I doubt this idea is original—it’s a combination of a few well-established ideas—but I’m also not aware of any calculator (or programming language) that currently works this way.

I am fairly sure this is exactly how my calculators (a Casio fx-115ES PLUS and a TI-89) work…

I don't have any experience with Casio calculators, but my recollection of the TI-89 and HP's competitors that have computer algebra systems is that by default they won't switch your data from rationals to floats without asking or alerting you.

However, if you input a number containing a decimal point it will be represented as a floating point number and performing arithmetic between that and a rational will cause the rational to be coerced to a floating point number and yield a floating point result. (If you're working with a more complicated expression, you can sometimes end up with some terms/coefficients of the expression being rational numbers and some being floats, until you ask for the expression to be fully evaluated down to a numerical result.)

They will fall back if they cannot represent the number as a rational; I just pulled them out and had them do \sum_{x=1}^{1000}\frac{1}{x^2} and they both gave me a decimal result.

The Windows calculator uses rationals with arbitrary precision too.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.