Enhancement Request: Fractions
Originally reported on Google Code with ID 424
When using some of these fancy calculators, they let the user specify numbers in terms of fractions. The calculator then prints the result in a fraction. It allows for switching back and forth between decimal and fraction forms of the number.
Reported by nathanila
on 2013-01-09 18:31:05
Comments (5)
-
Account Deleted -
This might not even require the introduction of a new rational type (concurrent to
HNumber
). I propose we do all the calculations with the existing high precision floating point types, and only when displaying the result, we could try to cast it into a fraction.This can be done by using a continued fraction scheme (one is already in use for units, which are coming soon). Simply put, we try to find a fraction with a denominator smaller than say 1'000'000, that has a value very close to the original number (choose the relative tolerance e.g. as 10^-60). When we find such a fraction, we can be reasonably sure that it is equal to the original number. Otherwise the number is either not rational, or its denominator is so large that it would more convenient to display just as a float.
-
Issue
#717was marked as a duplicate of this issue. -
Issue
#840was marked as a duplicate of this issue. -
This is what calculators call "pretty printing" and it's a great usability improvement. It should also factorize constants out, ie:
arcsin(1)
should tell mepi/2
instead of1,57079632679489661923
- Log in to comment
Reported by
helder.pereira.correia
on 2014-11-28 17:29:37 - Labels added: Type-Enhancement