You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Neidhart (JIRA)" <ji...@apache.org> on 2015/04/21 16:49:58 UTC

[jira] [Updated] (MATH-1196) FastMath.round (like Math.round) returns surprising results for some arguments

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

Thomas Neidhart updated MATH-1196:
----------------------------------
    Attachment: MATH-1196.patch

Attached a patch derived from jafama project (Apache licensed).

The change is derived from a posting to the openjdk mailinglist:

http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-August/020247.html

> FastMath.round (like Math.round) returns surprising results for some arguments
> ------------------------------------------------------------------------------
>
>                 Key: MATH-1196
>                 URL: https://issues.apache.org/jira/browse/MATH-1196
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.4.1
>            Reporter: Phil Steitz
>         Attachments: MATH-1196.patch
>
>
> The first assertion in the test case below succeeds, but the second fails
> {code}
>  /*
>      * http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6430675
>      */
>     @Test
>     public void testRoundDown() {
>         final double x = 0x1.fffffffffffffp-2;
>         Assert.assertTrue(x < 0.5d);
>         Assert.assertEquals(0, FastMath.round(x));
>     }
> {code}
> This is being tracked as a JDK (actually spec) bug here:
> http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6430675



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)