Recently I have come across some strange things. I know that java language takes positive and negative zero differently than our logical mathematical brain will take. Well the two are certainly different but how does java identifies them? Or more basic question... does java even differenciate between positive and negative zero? The truth is that IEEE floating point specification differentiates between positive and negative zero, but the java specification says that positive zero is equal to negative zero. Please go through the following code and see if you can satisfy your questions...
I am still not able to understand why I am not getting -0 at 2nd and 4th place. I have posted this in javaranch forums, lets see if I can get some clarification. If you have the answer please comment.