File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes // Math.sqrt() question 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 "// Math.sqrt() question " Watch "// Math.sqrt() question " New topic
Author

// Math.sqrt() question

Meg Adal
Ranch Hand

Joined: Mar 12, 2002
Posts: 70
As per API

public static double sqrt(double a)
Returns the square root of a double value.
Parameters:
a - a double value.
Returns:
the square root of a. If the argument is NaN or less than zero, the result is NaN.


So I wrote a code

Why it is not giving me NaN for double
Can anybody explain me or give the link which explains diff. behavior for Double's Min and Max values
Thanks in advance
Megan
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Double.MIN_VALUE is not a negative number. It is the smallest positive number representable as a double.
In my opinion, the designers of Java made a mistake in using the same symbol (MIN_VALUE) to mean two quite different things for Integer vs. Double.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Check out the definitions for Double.MIN_VALUE and Integer.MIN_VALUE:
static double MIN_VALUE: The smallest positive value of type double.
static int MIN_VALUE: The smallest value of type int.
So, by def'n Double.MIN_VALUE is positive, so you'll get an answer. Integer.MIN_VALUE is negative, so you'll get NaN


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: // Math.sqrt() question