• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

addition accuracy

 
Jason Hocker
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does this return the value 55296.19000000006? How can I get 55296.19?

 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Point #20 in the JavaBeginnersFaq covers this.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic