Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Power function in c language
Power function in c language
Pow () function is used to find the y power of x, x, y and function values are all double types, and its prototype is: double pow(double x, double y).

The sample code is as follows:

# include & ltstdio.h & gt

# include & ltmath.h & gt

void main()

{

double x = 2,y = 10;

printf("%f\n ",pow(x,y));

Returns 0;

}

Extended data:

When calling the pow function, it may cause an error:

If the base x is negative and the exponent y is not an integer, it will lead to a domain error.

If the base x and exponent y are both 0, it may lead to domain error? Wrong, or maybe not; This is related to the implementation of the library.

If radix x is 0 and exponent y is negative, it may lead to? Domain error or pole error, or not; This is related to the implementation of the library.

If the return value ret is too large or too small, it will lead to the range error error.

Error code:

If a domain error occurs, the global variable errno will be set to? EDOM;

If there is a pole error or a range error, the global variable errno will be set to ERANGE.

References:

Power Function-Baidu Encyclopedia