FastMath scalb() does not handle large magnitude exponents correctly
--------------------------------------------------------------------

                 Key: MATH-502
                 URL: https://issues.apache.org/jira/browse/MATH-502
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 2.2, 3.0
            Reporter: Sebb
             Fix For: 2.2, 3.0


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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to