Hi,
The following piece of code is producing an odd result. Upon execution
s1="2199.76" whilst strangely s2="2199.77".
java.text.DecimalFormat DF = new java.text.DecimalFormat("#,##0.00", new
DecimalFormatSymbols( Locale.US ) );
double d1 = 2199.76;
String s1 = DF.format( d1 );
double d2 = 2199.7599999999998;
String s2 = DF.format( d2 );
Does anyone have any thoughts on why this is the case? Is it simply a bug in
DecimalFormat?
Note that Sun's jvm produces "2199.76" for both strings.
Lars-Inge Tønnessen [VJ# MVP] - 21 Jul 2005 19:46 GMT
> Note that Sun's jvm produces "2199.76" for both strings.
> Is it simply a bug in DecimalFormat?
Yes, most likely. They should give the same result.
Regards,
Lars-Inge Tønnessen