commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (MATH-499) FastMath nextAfter(double,double) bugs with special doubles
Date Sun, 23 Jan 2011 12:24:43 GMT

     [ https://issues.apache.org/jira/browse/MATH-499?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sebb resolved MATH-499.
-----------------------

       Resolution: Fixed
    Fix Version/s: 3.0
                   2.2

Fixed in:

URL: http://svn.apache.org/viewvc?rev=1062387&view=rev
Log:
fixed nextAfter implementations for handling of some special values
fixed the signature of the float version, as the spec is to have a double second argument
moved the existing tests that were used in the former implementation in MathUtils,
fixing them also as two of them were not compliant with the spec for equal numbers
Jira: MATH-478

and

URL: http://svn.apache.org/viewvc?rev=1062385&view=rev
Log:
fixed nextAfter implementations for handling of some special values
fixed the signature of the float version, as the spec is to have a double second argument
moved the existing tests that were used in the former implementation in MathUtils,
fixing them also as two of them were not compliant with the spec for equal numbers
Jira: MATH-478

> FastMath nextAfter(double,double) bugs with special doubles
> -----------------------------------------------------------
>
>                 Key: MATH-499
>                 URL: https://issues.apache.org/jira/browse/MATH-499
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.2, 3.0
>         Environment: Java 1.6
>            Reporter: Sebb
>            Assignee: Sebb
>             Fix For: 2.2, 3.0
>
>
> nextAfter(double, double) is added in StrictMath 1.6, so one needs to test with Java
1.6 to see thi.
> There are various boundary errors with nextAfter(double, double) - see below.
> I think these are partially due to missing checks for special cases (e.g. the NaNs),
and partially due to the following code:
> {code}
> if (d * (direction - d) >= 0) {
> // we should increase the mantissa
> {code}
> This appears to be a shorthand for something like:
> {code}
> if (((d >=0) && (direction >= d)) || ((d<0) && (direction <0)))
{
> // we should increase the mantissa
> {code}
> however the expression (direction - d) overlows for some double values, thus causing
the wrong branch to be taken.
> double nextAfter(-0.0, -0.0) expected -0.0 actual 4.9E-324 entries [1, 1]
> double nextAfter(-0.0, 0.0) expected 0.0 actual 4.9E-324 entries [1, 2]
> double nextAfter(-0.0, NaN) expected NaN actual 4.9E-324 entries [1, 3]
> double nextAfter(0.0, -0.0) expected -0.0 actual 4.9E-324 entries [2, 1]
> double nextAfter(0.0, 0.0) expected 0.0 actual 4.9E-324 entries [2, 2]
> double nextAfter(0.0, NaN) expected NaN actual 4.9E-324 entries [2, 3]
> double nextAfter(-Infinity, NaN) expected NaN actual -Infinity entries [4, 3]
> double nextAfter(Infinity, NaN) expected NaN actual Infinity entries [5, 3]
> double nextAfter(-1.7976931348623157E308, NaN) expected NaN actual -1.7976931348623155E308
entries [6, 3]
> double nextAfter(1.7976931348623157E308, NaN) expected NaN actual 1.7976931348623155E308
entries [7, 3]
> double nextAfter(-1.1102230246251565E-16, NaN) expected NaN actual -1.1102230246251564E-16
entries [8, 3]
> double nextAfter(1.1102230246251565E-16, NaN) expected NaN actual 1.1102230246251564E-16
entries [9, 3]
> double nextAfter(-2.2250738585072014E-308, -0.0) expected -2.225073858507201E-308 actual
-2.225073858507202E-308 entries [10, 1]
> double nextAfter(-2.2250738585072014E-308, 0.0) expected -2.225073858507201E-308 actual
-2.225073858507202E-308 entries [10, 2]
> double nextAfter(-2.2250738585072014E-308, NaN) expected NaN actual -2.225073858507201E-308
entries [10, 3]
> double nextAfter(-2.2250738585072014E-308, 1.1102230246251565E-16) expected -2.225073858507201E-308
actual -2.225073858507202E-308 entries [10, 9]
> double nextAfter(-2.2250738585072014E-308, 2.2250738585072014E-308) expected -2.225073858507201E-308
actual -2.225073858507202E-308 entries [10, 11]
> double nextAfter(-2.2250738585072014E-308, -4.9E-324) expected -2.225073858507201E-308
actual -2.225073858507202E-308 entries [10, 12]
> double nextAfter(-2.2250738585072014E-308, 4.9E-324) expected -2.225073858507201E-308
actual -2.225073858507202E-308 entries [10, 13]
> double nextAfter(2.2250738585072014E-308, -0.0) expected 2.225073858507201E-308 actual
2.225073858507202E-308 entries [11, 1]
> double nextAfter(2.2250738585072014E-308, 0.0) expected 2.225073858507201E-308 actual
2.225073858507202E-308 entries [11, 2]
> double nextAfter(2.2250738585072014E-308, NaN) expected NaN actual 2.225073858507201E-308
entries [11, 3]
> double nextAfter(2.2250738585072014E-308, -1.1102230246251565E-16) expected 2.225073858507201E-308
actual 2.225073858507202E-308 entries [11, 8]
> double nextAfter(2.2250738585072014E-308, -2.2250738585072014E-308) expected 2.225073858507201E-308
actual 2.225073858507202E-308 entries [11, 10]
> double nextAfter(2.2250738585072014E-308, -4.9E-324) expected 2.225073858507201E-308
actual 2.225073858507202E-308 entries [11, 12]
> double nextAfter(2.2250738585072014E-308, 4.9E-324) expected 2.225073858507201E-308 actual
2.225073858507202E-308 entries [11, 13]
> double nextAfter(-4.9E-324, -0.0) expected -0.0 actual -1.0E-323 entries [12, 1]
> double nextAfter(-4.9E-324, 0.0) expected -0.0 actual -1.0E-323 entries [12, 2]
> double nextAfter(-4.9E-324, NaN) expected NaN actual -0.0 entries [12, 3]
> double nextAfter(-4.9E-324, 1.1102230246251565E-16) expected -0.0 actual -1.0E-323 entries
[12, 9]
> double nextAfter(-4.9E-324, 2.2250738585072014E-308) expected -0.0 actual -1.0E-323 entries
[12, 11]
> double nextAfter(-4.9E-324, 4.9E-324) expected -0.0 actual -1.0E-323 entries [12, 13]
> double nextAfter(4.9E-324, -0.0) expected 0.0 actual 1.0E-323 entries [13, 1]
> double nextAfter(4.9E-324, 0.0) expected 0.0 actual 1.0E-323 entries [13, 2]
> double nextAfter(4.9E-324, NaN) expected NaN actual 0.0 entries [13, 3]
> double nextAfter(4.9E-324, -1.1102230246251565E-16) expected 0.0 actual 1.0E-323 entries
[13, 8]
> double nextAfter(4.9E-324, -2.2250738585072014E-308) expected 0.0 actual 1.0E-323 entries
[13, 10]
> double nextAfter(4.9E-324, -4.9E-324) expected 0.0 actual 1.0E-323 entries [13, 12]

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


Mime
View raw message