+ 6
Because of Double.NaN (literally: “Not a Number”). This code: final double d1 = Double.NaN; final double d2 = Double.NaN; System.out.println(d1 == d2); will print false. The most accurate way to tell whether two double values are equal to one another is to use Double.compare() and test against 0, as in: System.out.println(Double.compare(d1, d2) == 0);
6th Nov 2020, 7:22 PM
WarLord
WarLord - avatar
0
Intresting, I also didn't know that.
6th Nov 2020, 7:31 PM
Coding Cat
Coding Cat - avatar