Double a = new Double(Double.NaN);
Double b = new Double(Double.NaN);
if( Double.NaN == Double.NaN )
System.out.println("True");
else
System.out.println("False");
That is a feature of NaN. It is not equal to itself.
Double a = new Double(Double.NaN);
Double b = new Double(Double.NaN);
if( Double.NaN == Double.NaN )
System.out.println("True");
else
System.out.println("False");
if( a.equals(b) )
System.out.println("True");
else
System.out.println("False");
If d1 and d2 both represent Double.NaN, then the equals method returns true, even though Double.NaN==Double.NaN has the value false.
Originally posted by Mr. C Lamont Gilbert:
I read your post in disbelief. Then I read the API. Let me apologize for this heinous abomination put forth by Sun. They should be completely ashamed of them selves making Double.NaN == Double.NaN return false.
This is a HIGH abomination.
Originally posted by Ernest Friedman-Hill:
Ummm.... you might want to leave Sun alone and take this up with the IEEE 754 committee. Here is a non-Java-related secondary reference which describes this property of NaN (the standard itself isn't free.)
[OCP 21 Professional Study Guide] [OCP 17 Complete Study Guide] [OCP 17 Practice Tests] [OCP 11 Complete Study Guide] [OCP 11 Programmer I] [OCP 11 Programmer II] [OCP 11 Practice Tests] [OCA 8] [OCP 8] [OCP 8 Practice Tests Book] [Blog]
My, that is even worse than what I say about addActionListener(this).This is a HIGH abomination.
Consider Paul's rocket mass heater. |