dividing double by double gives weird results - Java
Posted
by Aly
on Stack Overflow
See other posts from Stack Overflow
or by Aly
Published on 2010-03-18T00:34:01Z
Indexed on
2010/03/18
0:41 UTC
Read the original article
Hit count: 714
Hi,
I am trying to do the following 33.33333333333333/100.0
to get 0.333333333333333
however when I run System.out.println(33.33333333333333/100.0);
I get 0.33333333333333326
as the output, similarly when I run System.out.println(33.33333333333333/1000.0);
I get 0.033333333333333326
as the output. Does anyone know why, and how I can get the correct value (without loss of decimal places).
Thanks
© Stack Overflow or respective owner