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)
======================================================================
- duplicates
-
JDK-4106664 API: java.text.DecimalFormat.format(long n) fails if n * multiplier > MAX_LONG
-
- Closed
-