99999999999999.999 gets rounded
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   som_Halikhed
Posted On:   Tuesday, November 6, 2001 05:29 AM

The problem is with following code

			
public static void main(String args[]){
DecimalFormat form = new DecimalFormat("0.000");
double f= 99999999999999.999;
Double ft = new Double(f);
System.out.println("Formated :" + form.format(f));

}


This always prints 100000000000000.000
What is wrong with the code?

Re: 99999999999999.999 gets rounded

Posted By:   Christopher_Schultz  
Posted On:   Wednesday, November 14, 2001 12:10 PM

Nothing. IEEE roundoff says that
99999999999999.999 == 100000000000000.000.



Is there that much difference betwen the two values?



If you are doing super-precise mathematical calculations, don't use double values; use Long values and your own "power of ten" multiplier.



-chris
About | Sitemap | Contact