Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/DoubleNaN2.java
T
Tagir Valeevandintellij-monorepo-bot fa99f2dd20 [java-dfa] Do not rely on equivalence relation for floating point types
Fixes IDEA-339464 "Constant values" false positive for NaN

GitOrigin-RevId: a7b824f8d6ba0d6a8e4c9dd402ed6810a60e0066
2023-12-01 18:37:17 +00:00

19 lines
308 B
Java

public class DoubleNaN2 {
public static int compare(double lhs, double rhs) {
if (lhs == rhs) {
return 0;
}
if (lhs < rhs) {
return -1;
}
if (lhs > rhs) {
return 1;
}
if (Double.isNaN(lhs)) {
return Double.isNaN(rhs) ? 0 : -1;
}
return 1;
}
}