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

According to this java.sun page == is the equality comparison operator for floating point numbers in Java. However, when I type this code: if(sectionID == currentSectionID) into my editor and run static analysis, I get: “JAVA0078 Floating point values compared with ==” What is wrong with using == to compare floating point values? What is … Read more

How dangerous is it to compare floating point values?

I know UIKit uses CGFloat because of the resolution independent coordinate system. But every time I want to check if for example frame.origin.x is 0 it makes me feel sick: if (theView.frame.origin.x == 0) { // do important operation } Isn’t CGFloat vulnerable to false positives when comparing with ==, <=, >=, <, >? It … Read more