Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why is -0.0 equal (==) to 0 ?

843789Dec 1 2009 — edited Dec 1 2009
Hi Folks,

In this code ,
package flowcontrol;

public class Fc12 {
	public static void main(String[] args) {
		if(-0.0==0)
		{
			System.out.println("HIII");
		}
	}
}
O/P : HIII
Why is the negative decimal zero equal to 0 ? Also even negative decimal zero equal to positive decimal zero ?

Can someone give me some pointers.

Thank you for your consideration.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 29 2009
Added on Dec 1 2009
21 comments
2,275 views