Paul Clapham wrote:That number must be the nearest approximation you can make to the decimal number 2.9 using a float value, which is stored in binary rather than decimal form. If you're asking why you get 2.9 instead of 2.85, I invite you to display the contents of the intermediate string.
Hi paul, thanks for your reply.
Actually I would expect 2,9 as result, as you suggested.
I don't understand why I am getting 2.89999 instead of a rounded value of 2.9.
this can be brought back to the following result:
Should I switch to double instead of float?
marcello marangio wrote:Should I switch to double instead of float?
That won't help. See #20 in the JavaBeginnersFaq.