You were redirected to cplusplus.com/pow || See search results for: "pow"
function
<cmath> <ctgmath>

pow

double pow (double base, double exponent);
     double pow  (double base     , double exponent);
      float powf (float base      , float exponent);
long double powl (long double base, long double exponent);
     double pow (double base     , double exponent);
      float pow (float base      , float exponent);
long double pow (long double base, long double exponent);
     double pow (double base     , int exponent);
long double pow (long double base, int exponent);
     double pow (double base     , double exponent);
      float pow (float base      , float exponent);
long double pow (long double base, long double exponent);
     double pow (Type1 base      , Type2 exponent);        // additional overloads
Raise to power
Returns base raised to the power exponent:

baseexponent

Header <tgmath.h> provides a type-generic macro version of this function.
This function is overloaded in <complex> and <valarray> (see complex pow and valarray pow).
Additional overloads are provided in this header (<cmath>) for other combinations of arithmetic types (Type1 and Type2): These overloads effectively cast its arguments to double before calculations, except if at least one of the arguments is of type long double (in which case both are casted to long double instead).

This function is also overloaded in <complex> and <valarray> (see complex pow and valarray pow).

Parameters

base
Base value.
exponent
Exponent value.

Return Value

The result of raising base to the power exponent.

If the base is finite negative and the exponent is finite but not an integer value, it causes a domain error.
If both base and exponent are zero, it may also cause a domain error on certain implementations.
If base is zero and exponent is negative, it may cause a domain error or a pole error (or none, depending on the library implementation).
The function may also cause a range error if the result is too great or too small to be represented by a value of the return type.

If a domain error occurs, the global variable errno is set to EDOM.
If a pole or range error occurs, the global variable errno is set ERANGE.
If a domain error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to EDOM.
- And math_errhandling has MATH_ERREXCEPT set: FE_INVALID is raised.

If a pole error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to ERANGE.
- And math_errhandling has MATH_ERREXCEPT set: FE_DIVBYZERO is raised.

If a range error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to ERANGE.
- And math_errhandling has MATH_ERREXCEPT set: either FE_OVERFLOW or FE_UNDERFLOW is raised.

Example

1
2
3
4
5
6
7
8
9
10
11
/* pow example */
#include <stdio.h>      /* printf */
#include <math.h>       /* pow */

int main ()
{
  printf ("7 ^ 3 = %f\n", pow (7.0, 3.0) );
  printf ("4.73 ^ 12 = %f\n", pow (4.73, 12.0) );
  printf ("32.01 ^ 1.54 = %f\n", pow (32.01, 1.54) );
  return 0;
}


Output:

7 ^ 3 = 343.000000
4.73 ^ 12 = 125410439.217423
32.01 ^ 1.54 = 208.036691

See also