File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Min and Max problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Min and Max problem" Watch "Min and Max problem" New topic
Author

Min and Max problem

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Can someone explain this answer to me
System.out.println(Math.min(-0.0,+0.0));
System.out.println(Math.max(0.0,+0.0));
System.out.println(Math.min(-0.0,+0.0)==Math.max(0.0,+0.0));
It prints out
-0.0
0.0
true.
Is -0.0 same as 0.0 .
Thanks
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Don't get , its a simple rule.
Yes. Positive zero and negative zero are considered equal. Therefore, -0.0==0.0 is true. Its a rule of the language.
Read more about such rules in JLS.

Ajith

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks
cmacpher
Greenhorn

Joined: Oct 11, 2002
Posts: 1
Not in Oracle +0 = 0 > -0 This is true in 7.x 8.x 9.x
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
cmacpher,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name (change it here) to comply with our unique rule. Thank you.
PS: Quote from the naming policy:

For your publicly displayed name, use a first name, a space, and a last name. Obviously fictitious names or improperly formatted names may be locked out.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Min and Max problem