This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Min and Max problem

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
cmacpher
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not in Oracle +0 = 0 > -0 This is true in 7.x 8.x 9.x
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic