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

format function of NumberFormat/DecimalFormat

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.3
    • core-libs
    • x86
    • windows_nt



      Name: nl37777 Date: 02/16/99


      String s = "";
      BigDecimal bd = new BigDecimal(""+4480.1900000000005);
      bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
      System.out.println("Scale : " + bd.scale());
      System.out.println("Double : " + bd.doubleValue());
      double pValue = bd.doubleValue();
      System.out.println(pValue);
      java.text.DecimalFormat nf = (DecimalFormat) NumberFormat.getCurrencyInstance();
      s = nf.format(pValue);
      System.out.println("Return Value : " + s);

      for 4480.19 it always displays $4,480.18. But it works fine with other numbers.

      If BigDecimal is not used it works fine.
      (Review ID: 41248)
      ======================================================================

            duke J. Duke
            nlindenbsunw Norbert Lindenberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: