aspose file tools*
The moose likes Java in General and the fly likes addition accuracy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "addition accuracy" Watch "addition accuracy" New topic
Author

addition accuracy

Jason Hocker
Ranch Hand

Joined: Jul 23, 2003
Posts: 132
Why does this return the value 55296.19000000006? How can I get 55296.19?

Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Floating point numbers usually don't have exact representations. When you print out a double, you can use the DecimalFormat class.
Joe Vahabzadeh
Ranch Hand

Joined: Jan 05, 2005
Posts: 140
I think the only case where you're guaranteed 100% accuracy is when the fractional parts of the values involved can be represented by sums of negative powers of 2.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42280
    
  64
Point #20 in the JavaBeginnersFaq covers this.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: addition accuracy