Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

pow, powf, powl - General exponential function

&pagelevel(4)&pagelevel

Definition   

#include <math.h>

double pow(double x, double y);
float powf(float x, float y); (C11)
long double powl(long double x, long double y); (C11)

These functions compute xy.
If x is 0, y must be positive;
if x is negative, y must be an integer value.

Return val.

x y

if x, y and the result are in the permissible range of floating-point numbers.


+/-HUGE_VAL
+/-HUGE_VALF
+/-HUGE_VALL

depending on the function type and the sign of x, in the event of an overflow.
In addition, errno is set to ERANGE (result too large).


1.0

if x and y are equal to 0.


-HUGE_VAL
-HUGE_VALF
-HUGE_VALL

depending on the function type, if x is equal to 0 and y is less than 0.
In addition, errno is set to EDOM.


undefined

if x is less than 0 and y is not an integer.
In addition, errno is set to EDOM.

Example

The following program calculates xy for the input arguments x and y.

#include <math.h>
#include <stdio.h>
int main(void)
{
  double x, y;
  scanf("%lf %lf", &x, &y);
  printf("%g**%g : %g\n", x, y, pow(x,y));
  return 0;
}

See also

exp, hypot, log, log10, sinh, sqrt