• Post Reply Bookmark Topic Watch Topic
  • New Topic

double and float loosing precision - java core knowledge  RSS feed

 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,



The output of this program is:

50.12333
0.12333000000000283
float ----------------------
50.12333
0.12332916


Can anyone explain these values? I would expect no loss of precision with such small values!
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
value doesn't matter when you're dealing with floating point arithmetic. There's no magical number after which suddenly you start to loose precision, no magic formula that will tell you if and if so how much precision will be lost at any point.

http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!