Java Number Power pow(double a, double b)

Here you can find the source of pow(double a, double b)

Description

Returns the value of the first argument raised to the power of the second argument.

License

Open Source License

Parameter

Parameter Description
a the base.
b the exponent.

Return

the value ab.

Declaration

public static double pow(double a, double b) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   ww w  .  j av  a2 s .  c  o  m
     * Returns the value of the first argument raised to the power of the second
     * argument. Special cases:
     * 
     * <ul>
     * <li>
     * If the second argument is positive or negative zero, then the result is
     * 1.0.</li>
     * <li>
     * If the second argument is 1.0, then the result is the same as the first
     * argument.</li>
     * <li>
     * If the second argument is NaN, then the result is NaN.</li>
     * <li>
     * If the first argument is NaN and the second argument is nonzero, then the
     * result is NaN.</li>
     * <li>
     * If
     * 
     * <ul>
     * <li>
     * the absolute value of the first argument is greater than 1 and the second
     * argument is positive infinity, or</li>
     * <li>
     * the absolute value of the first argument is less than 1 and the second
     * argument is negative infinity,</li>
     * </ul>
     * 
     * then the result is positive infinity.</li>
     * <li>
     * If
     * 
     * <ul>
     * <li>
     * the absolute value of the first argument is greater than 1 and the second
     * argument is negative infinity, or</li>
     * <li>
     * the absolute value of the first argument is less than 1 and the second
     * argument is positive infinity,</li>
     * </ul>
     * 
     * then the result is positive zero.</li>
     * <li>
     * If the absolute value of the first argument equals 1 and the second
     * argument is infinite, then the result is NaN.</li>
     * <li>
     * If
     * 
     * <ul>
     * <li>
     * the first argument is positive zero and the second argument is greater
     * than zero, or</li>
     * <li>
     * the first argument is positive infinity and the second argument is less
     * than zero,</li>
     * </ul>
     * 
     * then the result is positive zero.</li>
     * <li>
     * If
     * 
     * <ul>
     * <li>
     * the first argument is positive zero and the second argument is less than
     * zero, or</li>
     * <li>
     * the first argument is positive infinity and the second argument is
     * greater than zero,</li>
     * </ul>
     * 
     * then the result is positive infinity.</li>
     * <li>
     * If
     * 
     * <ul>
     * <li>
     * the first argument is negative zero and the second argument is greater
     * than zero but not a finite odd integer, or</li>
     * <li>
     * the first argument is negative infinity and the second argument is less
     * than zero but not a finite odd integer,</li>
     * </ul>
     * 
     * then the result is positive zero.</li>
     * <li>
     * If
     * 
     * <ul>
     * <li>
     * the first argument is negative zero and the second argument is a positive
     * finite odd integer, or</li>
     * <li>
     * the first argument is negative infinity and the second argument is a
     * negative finite odd integer,</li>
     * </ul>
     * 
     * then the result is negative zero.</li>
     * <li>
     * If
     * 
     * <ul>
     * <li>
     * the first argument is negative zero and the second argument is less than
     * zero but not a finite odd integer, or</li>
     * <li>
     * the first argument is negative infinity and the second argument is
     * greater than zero but not a finite odd integer,</li>
     * </ul>
     * 
     * then the result is positive infinity.</li>
     * <li>
     * If
     * 
     * <ul>
     * <li>
     * the first argument is negative zero and the second argument is a negative
     * finite odd integer, or</li>
     * <li>
     * the first argument is negative infinity and the second argument is a
     * positive finite odd integer,</li>
     * </ul>
     * 
     * then the result is negative infinity.</li>
     * <li>
     * If the first argument is finite and less than zero
     * 
     * <ul>
     * <li>
     * if the second argument is a finite even integer, the result is equal to
     * the result of raising the absolute value of the first argument to the
     * power of the second argument</li>
     * <li>
     * if the second argument is a finite odd integer, 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 argument</li>
     * <li>
     * if the second argument is finite and not an integer, then the result is
     * NaN.</li>
     * </ul>
     * 
     * </li>
     * <li>
     * If both arguments are integers, then the result is exactly equal to the
     * mathematical result of raising the first argument to the power of the
     * second argument if that result can in fact be represented exactly as a
     * <code>double</code> value.</li>
     * </ul>
     * 
     * <p>
     * (In the foregoing descriptions, a floating-point value is considered to
     * be an integer if and only if it is finite and a fixed point of the method
     * {@link #ceil <tt>ceil</tt>} or, equivalently, a fixed point of the method
     * {@link #floor <tt>floor</tt>}. A value is a fixed point of a one-argument
     * method if and only if the result of applying the method to the value is
     * equal to the value.)
     * </p>
     * 
     * <p>
     * A result must be within 1 ulp of the correctly rounded result. Results
     * must be semi-monotonic.
     * </p>
     * 
     * @param a
     *            the base.
     * @param b
     *            the exponent.
     * 
     * @return the value <code>a<sup>b</sup></code>.
     */
    public static double pow(double a, double b) {
        return Math.pow(a, b);
    }
}

Related

  1. pow(double a, double b)
  2. pow(double a, double b)
  3. pow(double a, double b)
  4. pow(double a, int b)
  5. pow(double base, double exp)
  6. pow(double base, int exp)
  7. pow(double base, int exp)