FIX: NumberFormat of a BigDecimal Truncates Fraction

SYMPTOMS

When you use the NumberFormat class to format a BigDecimal object, any digits following the decimal point will be truncated.

CAUSE

This is cause by a code defect.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug has been verified to occur in both the 3100 and 3200 series of the Microsoft virtual machine.


This problem was corrected in Windows 2000 Service Pack 1.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Compile and run the following code.
  2. Notice the output for the format() method compared to the doubleValue() method and the toString() method.

    NumberFormat.format() should include digits on the right side of the decimal point.
    import java.text.*;import java.math.*;public class NumberFormatTest {   public static void main (String[] args) throws Exception {     NumberFormat nf = NumberFormat.getInstance();    BigDecimal bd = new BigDecimal(1234.56);    System.out.println("Double value = \t\t"+bd.doubleValue());    System.out.println("toString() = \t\t"+bd.toString());    System.out.println("Number format = \t"+nf.format(bd));    System.in.read();  }}

REFERENCES

For additional information about the latest service pack for Windows 2000, click the article number below
to view the article in the Microsoft Knowledge Base:

260910 How to Obtain the Latest Windows 2000 Service Pack
For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:
Eigenschaften

Artikelnummer: 260968 – Letzte Überarbeitung: 14.02.2017 – Revision: 1

Microsoft Internet Explorer 4.0 128-Bit Edition, Microsoft Internet Explorer 4.01 Service Pack 2, Microsoft Internet Explorer 4.01 Service Pack 2, Microsoft Internet Explorer 4.01 Service Pack 1, Microsoft Internet Explorer 4.01 Service Pack 2, Microsoft Internet Explorer 4.01 Service Pack 2, Microsoft Software Development Kit for Java 2.02, Microsoft Software Development Kit für Java 3.0, Microsoft Software Development Kit für Java 3.0, Microsoft Software Development Kit für Java 3.0, Microsoft Software Development Kit für Java 3.0, Microsoft Software Development Kit for Java 3.1, Microsoft Software Development Kit for Java 3.2, Microsoft Software Development Kit for Java 4.0, Microsoft Visual J++ 6.0 Standard Edition

Feedback