Uploaded image for project: 'Commons Numbers'
  1. Commons Numbers
  2. NUMBERS-128

Precision of Fraction.floatValue() can be improved

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.0
    • None
    • fraction
    • None

    Description

      The current implementation of Fraction.floatValue() first calls doubleValue(), which converts the fraction to a double with maximum possible precision, and then rounds the returned double value to a float. For the fraction 1 + 26 / (230 - 1) = (230 - 1 + 26) / (230 - 1), this yields a result of exactly 1. However, the actual value of the fraction is closer to 1 + 2-23 (which is representable exactly as a float) than it is to 1, as WolframAlpha confirms.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Schamschi Heinrich Bohne
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: