Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4071492

DecimalFormat doesn't round

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.2, 1.1.6
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86, sparc
    • OS:
      solaris_2.6, windows_nt

      Description



      Name: bb33257 Date: 08/13/97


      Formatting 0.00159999 with 4 fractional digits should produce
      "0.0016". Instead, the result is 0.0015.

        double x = 0.00159999;
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(4);
        String out = nf.format(x);
        logln("0.00159999 formats with 4 fractional digits to " + out);
        String expected = "0.0016";
        if (!out.equals(expected)) errln("FAIL: Expected " + expected);
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            joconnersunw John Oconner (Inactive)
            Reporter:
            bcbeck Brian Beck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: