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

FastMath scalb() does not handle large magnitude exponents correctly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2, 3.0
    • Fix Version/s: 2.2, 3.0
    • Labels:
      None

      Description

      scalb does not handle MAX_VALUE exponents properly:

      double scalb(-1.7976931348623157E308, 2147483647) expected -Infinity actual -8.988465674311579E307 entries [6, 5]
      double scalb(1.7976931348623157E308, 2147483647) expected Infinity actual 8.988465674311579E307 entries [7, 5]
      double scalb(-1.1102230246251565E-16, 2147483647) expected -Infinity actual -5.551115123125783E-17 entries [8, 5]
      double scalb(1.1102230246251565E-16, 2147483647) expected Infinity actual 5.551115123125783E-17 entries [9, 5]
      double scalb(-2.2250738585072014E-308, 2147483647) expected -Infinity actual -0.0 entries [10, 5]
      double scalb(2.2250738585072014E-308, 2147483647) expected Infinity actual 0.0 entries [11, 5]

      float scalb(3.4028235E38, 2147483647) expected Infinity actual 1.7014117E38 entries [7, 5]
      float scalb(-3.4028235E38, 2147483647) expected -Infinity actual -1.7014117E38 entries [9, 5]

      It looks as though the problem is with the calculation of the scaledExponent - for large values, this can wrap round, so some of the checks against its value may give misleading results.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: