Why does this simple division between 2 floats not work with java ?
Posted
by user323186
on Stack Overflow
See other posts from Stack Overflow
or by user323186
Published on 2010-04-26T13:56:34Z
Indexed on
2010/04/26
14:13 UTC
Read the original article
Hit count: 129
System.out.println((26.55f/3f));
or
System.out.println((float)( (float)26.55 / (float)3.0 ));
etc.
returns the result 8.849999. not 8.85 as it should.
Can anyone explain this or should we all avoid using floats?
© Stack Overflow or respective owner