double pow ( double base, double exponent );
long double pow ( long double base, long double exponent );
float pow ( float base, float exponent ); |
|
Raise to power
Returns base raised to the power exponent:
baseexponent
Parameters
- base
- Floating point value.
- exponent
- Floating point value.
Return Value
The result of raising
base to the power
exponent.
If the magnitude of the result is so large that it cannot be represented in an object of the return type, a range error occurs, returning HUGE_VAL with the appropiate sign and setting the value of the global variable errno to the ERANGE value.
If base is negative and exponent is not an integral value, or if base is zero and exponent is negative, a domain error occurs, setting the global variable errno to the value EDOM.
Portability
In C, only the
double version of this function exists with this name.
Example
/* pow example */
#include <stdio.h>
#include <math.h>
int main ()
{
printf ("7 ^ 3 = %lf\n", pow (7,3));
printf ("4.73 ^ 12 = %lf\n", pow (4.73,12));
printf ("32.01 ^ 1.54 = %lf\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
log | Compute natural logarithm (function) |
exp | Compute exponential function (function) |
sqrt | Compute square root (function) |