java.text.DecimalFormat
- From: "Andy W." <Andy W.@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 20 Jul 2005 09:31:02 -0700
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.
.
- Follow-Ups:
- Re: java.text.DecimalFormat
- From: Lars-Inge Tønnessen [VJ# MVP]
- Re: java.text.DecimalFormat
- Prev by Date: calling functions of the inner class- parameters of action functio
- Next by Date: calling action function of the inner class in main function
- Previous by thread: calling functions of the inner class- parameters of action functio
- Next by thread: Re: java.text.DecimalFormat
- Index(es):