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

MathUtils.round incorrect result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1
    • None
    • None
    • None
    • Win2K, Sun JDK1.5.0_05 b05

    Description

      MathUtils.round(39.245, 2) results 39.24, however it should be 39.25, with default rounding mode BigDecimal.ROUND_HALF_UP.

      I found that internally MathUtils.round multiplies the given number by 10^scale.
      39.245 * 100.0 results 3924.49999...5 , and after this the calculation is not correct any more.

      Attachments

        1. math-151.patch
          11 kB
          Luc Maisonobe

        Issue Links

          Activity

            People

              Unassigned Unassigned
              buzaz Buza Zoltán
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: