What's wrong with using == to compare floats in Java?

后端 未结 21 2248
你的背包
你的背包 2020-11-22 01:00

According to this java.sun page == is the equality comparison operator for floating point numbers in Java.

However, when I type this code:



        
21条回答
  •  滥情空心
    2020-11-22 01:20

    What is wrong with using == to compare floating point values?

    Because it's not true that 0.1 + 0.2 == 0.3

提交回复
热议问题