Enhancement Request: Fractions

Issue #424 new
Former user created an issue

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)

  1. Former user Account Deleted

    Reported by helder.pereira.correia on 2014-11-28 17:29:37 - Labels added: Type-Enhancement

  2. Pol Welter

    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.

  3. Giuseppe C

    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 me pi/2 instead of 1,57079632679489661923

  4. Log in to comment