aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes about -0.0 and +0.0 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 "about -0.0 and +0.0" Watch "about -0.0 and +0.0" New topic
Author

about -0.0 and +0.0

david hu
Ranch Hand

Joined: Jul 20, 2001
Posts: 143
The answer of the question(from www.jtips.net mock ex2) is 2.But when I run the program, I got the following output:
Prints 0.0 , there's no +0.0
Is the answer wrong?
class Test {

Test() {
this(-0.0 == + 0.0);
}
Test(boolean b) {
if(b)
System.out.println(Math.max(-0.0, + 0.0));
else
System.out.println(Math.min(-0.0, + 0.0));
}
public static void main(String [] args) {
new Test();
}
}
1.Prints � 0.0
2.Prints + 0.0
3.Compile-time error occurs.
4.No output is printed.
Namrata Shetty
Ranch Hand

Joined: Jul 18, 2001
Posts: 30
u r right. 0.0 gets printed and not +0.0.
i think the question is trying to test if u know Math.max(-0.0,+0.0) function differentates between -0.0 & +0.0
Alex Sbityakov
Ranch Hand

Joined: Jul 23, 2001
Posts: 49
A better question would be to test the result of System.out.println(Math.min(-0.0,0.0))
 
 
subject: about -0.0 and +0.0