The pow() method of Math class returns the value of first argument raised to the power of second argument i.e. ab.

Syntax:

public static double pow(double a, double b)

Parameters:

The parameters ‘a’ and ‘b’ represent the base and the exponent.

Return Value:

The pow() method computes the value of ab.

Special cases of the pow() method are as follows:

• It returns 1.0, is second argument passed is positive or negative zero.
• It returns the result same as the first argument, if the second argument is 1.0.
• It returns NaN, is either argument is NaN.
• It returns positive infinity, if ‘a’ is greater than 1 and ‘b’ is positive infinity or ‘a’ is less than 1 and ‘b’ is negative infinity.
• It returns positive zero, if ‘a’ is greater than 1 and ‘b’ is negative infinity or ‘a’ is less than 1 and ‘b’ is positive infinity.
• It returns NaN, if absolute value of the first argument is equal to 1 and second argument is infinite.
• It returns positive zero, if ‘a’ is positive zero and ‘b’ is greater than zero or ‘a’ is positive infinity and ‘b’ is less than zero.
• It returns positive infinity, if ‘a’ is positive zero and ‘b’ is less than zero or ‘a’ is positive infinity and ‘b’ is greater than zero.
• It returns positive zero, if ‘a’ is negative zero and ‘b’ is greater than zero but not a finite odd integer or ‘a’ is negative infinity and ‘b’ is less than zero but not a finite odd integer.
• It returns negative zero, if ‘a’ is negative zero and ‘b’ is positive finite odd integer or ‘a’ is negative infinity and ‘b’ is negative finite odd integer.
• It returns positive infinity, if ‘a’ is negative zero and ‘b’ is less than zero but not a finite odd integer or ‘a’ is negative infinity and ‘b’ is greater than zero but not a finite odd integer.
• It returns negative infinity, if ‘a’ is negative zero and ‘b’ is negative finite odd integer or ‘a’ is negative infinity and ‘b’ is positive finite odd integer.
• It returns ab, if both the arguments are integers.

Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output:

Example 5:

Output: