3

I am trying to understand below output

System.out.println(4.0-3.2);

output is 0.7999999999999998

while it was expected to be 0.8

on the other hand

System.out.println(4.0+3.2);

is 7.2

System.out.println(2.0*0.2);

returns 0.4 why is so long value in case of System.out.println(4.0-3.2);

Can you please explain?

Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60
user419534
  • 635
  • 2
  • 8
  • 14
  • 2
    Uncountable number of duplicates here. [Is floating point math broken?](http://stackoverflow.com/q/588004/995714) – phuclv Jul 13 '15 at 11:19

0 Answers0