pow, powl
Calculates x to the power of y.
Defined in header <math.h>
Syntax
Real versions: Complex version:
#include <math.h> #include <complex,h>
double pow(double x, double y); complex pow(complex x, complex y);
long double powKlong double x, complex pow(complex x, double y);
long double y) complex pow(double x, complex y);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only | |
|---|---|---|---|---|---|
| powl | ■ | ■ | |||
| Real pow | ■ | ■ | ■ | ■ | |
| Complex pow | ■ | ■ | ■ |
Remarks
pow calculates x^. powl is the long double version; it takes long double arguments and returns a long double result.
The complex pow is defined by
poMvibase, expon) = expiexpon logibase))
Return value
On success, pow and powl return the value calculated, xV.
Sometimes the arguments passed to these functions produce results that overflow or are incalculable. When the correct value would overflow, the
| functions return the value HUGE_VAL | (pow) or _LHUGE_VAL | (powl). |
Results of excessively large magnitude can cause the global variable errno to be set to
ERANGE Result out of range
If the argument x passed to pow or powl is real and less than 0, and y is not a whole number, the global variable errno is set to
| EDOM | Domain error |
If the arguments x and y passed to pow or powl are both 0, they return 1.
Error handling for these functions can be modified through the functions matherr and _matherrl.
See also
Example
*include <math.h>
#include <stdio.h>
int main(void)
{
double X = 2.0, y = 3.0;
printf("%lf raised to %lf is %lf\n", x, y, pow(x, y));
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/math.h/pow/
· short form /3.1/pow/