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.
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).
:; sbcl
This is SBCL 1.5.5, an implementation of ANSI Common Lisp.
...
* (/ 1 3)
1/3