File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes == operator???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "== operator????" Watch "== operator????" New topic

== operator????

raymond yadao
Ranch Hand

Joined: Jan 29, 2001
Posts: 88
System.out.println(Math.min(-0.0,+0.0) == Math.max(0.0,+0.0));

why is this print true?
(min = -0.0) == (max = 0.0)???

another thing, how is the conversion of decimal in binary of negative numbers done?
48 = 11 0000
-48 = ???
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
Math.min(-0.0,+0.0) returns -0.0
Math.max(0.0,+0.0) returns 0.0
From JLS 15.21.1 Numerical Equality Operators == and !=

Positive zero and negative zero are considered equal. Therefore, -0.0==0.0 is true, for example.

The conversion of negative decimal numbers to binary has been heavily discussed in the following threads:

[Blog] [Blogroll] [My Reviews] My Linked In
It is sorta covered in the JavaRanch Style Guide.
subject: == operator????
Similar Threads
Take the Dr. Phil Test
Math.min and Math. max
Math class
what s the result
what this code returns true