Harmony
  1. Harmony
  2. HARMONY-988

[classlib][util] Formatting doubles: different behaviour with RI

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None
    • Estimated Complexity:
      Moderate

      Description

      This simple line produces different results using RI and Harmony VMs

      System.out.format("%.1f\n", 1.45);
      Harmony: 1.4
      RI: 1.5

      I think that this is our bug.

      I tried to find the source of the problem but faced with problem that I can't find sources for com.ibm.icu.text.DecimalFormat file.

      1. diff.txt
        3 kB
        Mike Ringrose

        Issue Links

          Activity

          Hide
          Alexey A. Ivanov added a comment -

          It seems to be a bug of Harmony, since 'f' formatter should use round half up algorithm. See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#dndec and http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#ROUND_HALF_UP respectively.

          Show
          Alexey A. Ivanov added a comment - It seems to be a bug of Harmony, since 'f' formatter should use round half up algorithm. See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#dndec and http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#ROUND_HALF_UP respectively.
          Hide
          Mike Ringrose added a comment -

          The attached patch resolves the differences with the RI and Harmony by doing half up rounding.

          Show
          Mike Ringrose added a comment - The attached patch resolves the differences with the RI and Harmony by doing half up rounding.
          Hide
          Mikhail Loenko added a comment -

          the patch causes failures of
          tests.api.java.util.FormatterTest

          Show
          Mikhail Loenko added a comment - the patch causes failures of tests.api.java.util.FormatterTest

            People

            • Assignee:
              Mikhail Loenko
              Reporter:
              Mikhail Fursov
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development