Java Reference
In-Depth Information
12. If the first argument is negative zero and the second argument is less than
zero,but not a finite odd integer,or the first argument is negative infinity
and the second argument is greater than zero,but not a finite odd integer,
then the result is positive infinity.
13. If the first argument is negative zero and the second argument is a negative
finite odd integer,or the first argument is negative infinity and the second
argument is a positive finite odd integer,then the result is negative infinity.
14. If the first argument is less than zero and the second argument is a finite
even integer,then the result is equal to the result of raising the absolute
value of the first argument to the power of the second argument.
15. If the first argument is less than zero and the second argument is a finite
odd integer,then the result is equal to the negative of the result of raising
the absolute value of the first argument to the power of the second argu-
ment.
16. If the first argument is finite and less than zero and the second argument is
finite and not an integer,then the result is NaN.
17. If both arguments are integers,then the result is exactly equal to the mathe-
matical result of raising the first argument to the power of the second argu-
ment if that result can in fact be represented exactly as a double value.
The following program demonstrates the use of the pow() method.
// Java for Engineers
// Filename: ExpoDemo
// Reference: Chapter 23
// Description:
//
Using the pow() function
import java.lang.*;
strictfp class ExpoDemo
{
public static void main(String[] args)
{
// Display the square root of 2 using sqrt()
System.out.print(“ sqrt(2.0) = ”);
System.out.println(Math.sqrt(2.0));
// Calculate and display using pow()
System.out.print(“pow(2.0, 0.5) = ”);
System.out.println(Math.pow(2.0, 0.5));
System.out.println();
}
}
Search WWH ::




Custom Search