JDK-4349833 : java.math.BigDecimal; DecimalFormat error after 15 digits
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-06-30
  • Updated: 2001-02-02
  • Resolved: 2001-02-02
Related Reports
Duplicate :  
Description

Name: stC104175			Date: 06/30/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

Formatting of BigDecimal Numbers of more than 15 digits produce false result.
Maybe the double Problem mentioned in: 4212074, 4106664, 4329840, 4330671
reported against JDK 1.2.X

DecimalFormat DFormat
=(DecimalFormat) (NumberFormat.getNumberInstance(new Locale("en", "us")));
DFormat.setDecimalSeparatorAlwaysShown(false);

BigDecimal BD15=new BigDecimal("999999999999999");
BigDecimal BD16=new BigDecimal("9999999999999999");

System.out.println(DFormat.format(BD15));
System.out.println(DFormat.format(BD16));

999,999,999,999,999
10,000,000,000,000,000
(Review ID: 106749) 
======================================================================

Comments
EVALUATION java.text.NumberFormat converts BigIntegers and BigDecimals into longs or doubles and then operates on those. Sometimes primitives cannot hold enough information to represent a BigDecimal value. It also looks like certain truncation problems might exist where a multi precision number gets silently truncated and then formatted. michael.mccloskey@eng 2000-07-05
05-07-2000