Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Simple question 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 "Simple question" Watch "Simple question" New topic
Author

Simple question

ji soi
Greenhorn

Joined: Jun 14, 2005
Posts: 13
System.out.println(Math.min(-0.0,+0.0) == Math.max(0.0,+0.0));
6: }

returns true.

can anyone explain me how ?
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
If you check out the Float API Spec, you'll see this under the description of the equals method:


Note that in most cases, for two instances of class Float, f1 and f2, the value of f1.equals(f2) is true if and only if

f1.floatValue() == f2.floatValue()


also has the value true. However, there are two exceptions:

* If f1 and f2 both represent Float.NaN, then the equals method returns true, even though Float.NaN==Float.NaN has the value false.
* If f1 represents +0.0f while f2 represents -0.0f, or vice versa, the equal test has the value false, even though 0.0f==-0.0f has the value true.

This definition allows hash tables to operate properly.

[ June 20, 2005: Message edited by: Corey McGlone ]

SCJP Tipline, etc.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Also note this post...

http://www.coderanch.com/t/249520/java-programmer-SCJP/certification/Majji-Comparision-results


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
ji soi
Greenhorn

Joined: Jun 14, 2005
Posts: 13
Thanks for ur clarification.

One more question

public First (String s) {

System.out.println(s);

}

}

public class Second extends First {

public static void main(String args []) {

new Second();

}

}

This program gives error " No constructor matching found in class first"

If i add empty constructor first()
it works.

I read in a book
Even if there is no constructor default const. will added by the compiler without no parameters.
then why is this error.

plz help me with this
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

The compiler will provide a no-args constructor only if no other constructors are specified. If you specify any constructor (arguments or not), then the compiler will not add one.
[ June 20, 2005: Message edited by: marc weber ]
 
 
subject: Simple question
 
Similar Threads
Math.min and Math. max
Math class
what s the result
what this code returns true
-0.0 and +0.0