pow
power function
You're viewing an older version of this page (#3327). View the current version.
NAME
pow
INTERFACE
#include <math.h>
double pow ( double x, double y ) long powl ( long double x, long double y ) float powf ( float x, float y )
DESCRIPTION
The pow functions compute x raised to the power y.
Example 1
#include <math.h>
#include <stdio.h>
int main(void)
{
double x = 10.0, y = 0.0;
do {
printf("The Power of %.1lf , %.1lfis %f\n", x,y, pow(x, y));
y++;
} while(y<7.0);
return 0;
}Output:
The Power of 10.0 , 0.0 is 1.000000
The Power of 10.0 , 1.0 is 10.000000
The Power of 10.0 , 2.0 is 100.000000
The Power of 10.0 , 3.0 is 1000.000000
The Power of 10.0 , 4.0 is 10000.000000
The Power of 10.0 , 5.0 is 100000.000000
The Power of 10.0 , 6.0 is 1000000.000000SPECIAL VALUES
pow ( ±0 , y ) returns ±∞ and raises the divide-by-zero floating-point exception for y an odd integer < 0.
pow ( ±0 , y ) returns +∞ and raises the divide-by-zero floating-point exception for y < 0 and not an odd integer.
pow ( ±0 , y ) returns ±0 for y an odd integer > 0.
pow ( ±0 , y ) returns +0 for y > 0 and not an odd integer.
pow ( -1 , ±∞ ) returns 1.
pow ( 1 , y ) returns 1 for any y, even a NaN.
pow ( x , ±0 ) returns 1 for any x, even a NaN.
pow ( x , y ) returns a NaN and raises the invalid floating-point exception for finite x < 0 and finite non-integer y.
pow ( x , -∞ ) returns +∞ for |x| < 1.
pow ( x , -∞ ) returns +0 for |x| > 1.
pow ( x , +∞ ) returns +0 for |x| < 1.
pow ( x , +∞ ) returns +∞ for |x| > 1.
pow ( -∞ , y ) returns -0 for y an odd integer < 0.
pow ( -∞ , y ) returns +0 for y < 0 and not an odd integer.
pow ( -∞ , y ) returns -∞ for y an odd integer > 0.
pow ( -∞ , y ) returns +∞ for y > 0 and not an odd integer.
pow ( +∞ , y ) returns +0 for y < 0.
pow ( +∞ , y ) returns +∞ for y > 0.
A domain error occurs if x is finite and negative and y is finite and not an integer.
A domain error can occur if x is 0 and y less than or equal to 0.
Range errors may occur.
STANDARDS
The pow function conforms to ISO/IEC 9899:1999(E).