This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what this code returns true Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "what this code returns true" Watch "what this code returns true" New topic
Author

what this code returns true

kavitha satteli
Greenhorn

Joined: Jul 31, 2007
Posts: 9
(0.0 == -0.0)
dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
hi thr

i dont know if i got your doubt or not
but will say
since the values +0.0 and -0.0 are identical
or same so it returns true..............
if you have some other doubt do let us know
please be specific with your doubt....?
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
In mathematical terms, +0.0 and -0.0 are the same, so that's why Java defines that comparison to return true. As you may know, it is true that +0.0 and -0.0 have different underlying bit representations, but you can't distinguish between them using the == operator.

However, the Double class does distinguish between the two, so this will print false:


SCJP 5.0
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: what this code returns true
 
Similar Threads
what s the result
Math class
-0.0 and +0.0
Math.min and Math. max
[about zero]...