This is surprising to me!
Casio scientific calculators definitely do this, and have done for many years now. And Casio (it appears) also represents pi and square roots exactly/symbolicly, wherever it's reasonable to do so.
>>> import fractions
>>> from fractions import Fraction as F
>>> F(3, 17) * F(12, 5) + F(56, 99)
Fraction(8324, 8415)
>>> F(3, 17) * F(12, 5) + F(56, 99) / 3 + 2 * 4
Fraction(217412, 25245)
However, if you use a float or a complex with it, the fraction get resolved: >>> F(217412, 25245) + 0.1
8.712081600316894
>>> F(217412, 25245) + 1j
(8.612081600316895+1j)
You also have some constants: >>> import math
>>> math.pi
3.141592653589793
>>> math.e
2.718281828459045
But they are not just symbol, there is a precision-limited value behind it. Although the value seems to match the precision NASA considers to be enough for trajectories of spacecrafts like Voyager: https://www.jpl.nasa.gov/edu/news/2016/3/16/how-many-decimal...Author here. The paraphrase makes this sound wrong, but what I actually meant is that I don’t know of any calculator that uses rationals while the numerator and denominator can be represented as integer floating point doubles, and then falls back to a single floating point double if the numerator or denominator overflow.
I am aware of many systems that use arbitrary precision rationals, and I mentioned this in the post:
> Rational numbers where the numerator and denominator are allowed to grow arbitrarily large are used by computer algebra systems (CAS) like Mathematica and Maple (and also some high-end handheld graphing calculators).
I am fairly sure this is exactly how my calculators (a Casio fx-115ES PLUS and a TI-89) work…
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.)
Because we made out calculator in JavaScript.
Relatedly, lately I've been thinking of floats not as numbers but as number intervals. Their arithmetic doesn't really work that way but it's much better intuition for all the weirdness.
Twenty or thirty is not a large number in many reasonable calculations, for instance with finite element calculations or Markov chanis.
https://iquilezles.org/www/articles/floatingbar/floatingbar....