Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-486

FastMath toRadian and toDegree don't handle large double numbers well

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2, 3.0
    • 2.2, 3.0
    • None
    • None

    Description

      FastMath toRadian and toDegree don't handle very large double numbers well.

      For example, toDegrees(Double.MAX_VALUE) => NaN, but it should be INFINITY
      and toRadian(Double.MAX_VALUE) => NaN instead of the proper value

      This is because of the lines:

      double temp = x * 1073741824.0; // == 0x40 00 00 00
      double xa = x + temp - temp; // => NaN for x large enough
      

      This seems to be an attempt to split x into a large and a small part, but fails when x >= MAX_VALUE / 1073741824.0

      Not sure how to fix this

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebb Sebb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: