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

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.1
    • Labels:
      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

            • Assignee:
              Unassigned
              Reporter:
              tn Thomas Neidhart

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment