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

2016-05-29 Thread Gilles (JIRA)

[ 
https://issues.apache.org/jira/browse/MATH-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15306110#comment-15306110
 ] 

Gilles commented on MATH-1196:
--

This fix should have been considered for inclusion in 3.6 or 3.6.1.

> 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.fp-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)


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

2015-12-29 Thread Phil Steitz (JIRA)

[ 
https://issues.apache.org/jira/browse/MATH-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15074323#comment-15074323
 ] 

Phil Steitz commented on MATH-1196:
---

The patch makes sense to me.  Assuming current and tests above pass, +1 to 
commit, adding (at least) test case above. 

> 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.fp-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)


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

2015-03-06 Thread ntysdd (JIRA)

[ 
https://issues.apache.org/jira/browse/MATH-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14351466#comment-14351466
 ] 

ntysdd commented on MATH-1196:
--

Both Java 6 and Java 7 fail this test.
Java 8 has a different implementation.

> 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
>
> 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.fp-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)


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

2015-03-06 Thread Phil Steitz (JIRA)

[ 
https://issues.apache.org/jira/browse/MATH-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14350699#comment-14350699
 ] 

Phil Steitz commented on MATH-1196:
---

Is the fix above in the code that fails this?

> 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
>
> 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.fp-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)


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

2015-03-06 Thread ntysdd (JIRA)

[ 
https://issues.apache.org/jira/browse/MATH-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14350188#comment-14350188
 ] 

ntysdd commented on MATH-1196:
--

Not so easy.
Still wrong.

public void test() {
final double x = 4503599627370497.0; // x = Math.pow(2, 52) + 1;
Assert.assertTrue(x == Math.rint(x));
Assert.assertTrue(x == FastMath.round(x));
}


> 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
>
> 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.fp-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)


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

2015-03-04 Thread Thomas Neidhart (JIRA)

[ 
https://issues.apache.org/jira/browse/MATH-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14347685#comment-14347685
 ] 

Thomas Neidhart commented on MATH-1196:
---

The implemented change in the jdk is very simple:

{code}
if (a != 0x1.fp-2) // greatest double value less than 0.5
return (long)floor(a + 0.5d);
else
return 0;
{code}

we could easily do the same.

> 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
>
> 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.fp-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)