• Post Reply Bookmark Topic Watch Topic
  • New Topic

Float explanation  RSS feed

 
Alix Ollivier
Ranch Hand
Posts: 71
Java Linux Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How come when I increment a float by 0.01 each update, this is what appears when I system.out.println the value of the float?

0.02
0.03
0.04
0.049999997
0.059999995
0.06999999
0.07999999
0.08999999
0.09999999
0.109999985
0.11999998
0.12999998
0.13999999
0.14999999
0.16
0.17
0.18
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See #20 in the https://www.coderanch.com/how-to/java/JavaBeginnersFaq
 
Alix Ollivier
Ranch Hand
Posts: 71
Java Linux Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!