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

FastMath.pow deviates from Math.pow for negative, finite base values with an exponent 2^52 < y < 2^53

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.1
    • None
    • None

    Description

      As reported by Jeff Hain:

      pow(double,double):
      Math.pow(-1.0,5.000000000000001E15) = -1.0
      FastMath.pow(-1.0,5.000000000000001E15) = 1.0
      ===> This is due to considering that power is an even
      integer if it is >= 2^52, while you need to test
      that it is >= 2^53 for it.
      ===> replace
      "if (y >= TWO_POWER_52 || y <= -TWO_POWER_52)"
      with
      "if (y >= 2*TWO_POWER_52 || y <= -2*TWO_POWER_52)"
      and that solves it.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tn Thomas Neidhart
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: