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

FastMath.round (like Math.round) returns surprising results for some arguments

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.1
    • 4.0
    • None
    • None

    Description

      The first assertion in the test case below succeeds, but the second fails

       /*
           * 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));
          }
      

      This is being tracked as a JDK (actually spec) bug here:
      http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6430675

      Attachments

        1. MATH-1196.patch
          3 kB
          Thomas Neidhart

        Activity

          People

            Unassigned Unassigned
            psteitz Phil Steitz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: