Home > DeveloperSection > Forums > How Autoboxing is going here?
ezra heywood
ezra heywood

Total Post:145

Points:1019
Posted on    April-28-2015 12:22 AM

 Java Java 
Ratings:


 1 Reply(s)
 423  View(s)
Rate this:
Hi there 

This is my code 

public class Autoboxing {
     
     
    public static void main(String[] args) {
 
               double x2 = 0.0/0.0, y2 = 0.0/0.0;
            Double a2 = x2, b2 = y2;
            StdOut.println(x2 == y2);
            StdOut.println(!a2.equals(b2));
    }
 
}

its Output is :
false 
false 

I am expecting 
true 
false


Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Supported
Posted on    April-28-2015 7:13 AM

I think it's something to do with the special value which you get when you divide zero by zero as double values

Because there are two different flavours of NAN, Double.POSITIVE_INFINITY and Double.NEGATIVE_INFINITY 
You can’t directly compare == Double.NAN to check for NAN. However, you can directly compare == Double.NAN; 
However, you can use Double.isNaN or == to compare with Double.POSITIVE_INFINITY.

Don't want to miss updates? Please click the below button!

Follow MindStick