Format
#include <math.h> double pow(double x, double y);
Language Level: ANSI
Threadsafe: Yes.
Description
The pow() function calculates the value of x to the power of y.
Return Value
If y is 0, the pow() function returns the value 1. If x is 0 and y is negative, the pow() function sets errno to EDOM and returns 0. If both x and y are 0, or if x is negative and y is not an integer, the pow() function sets errno to EDOM, and returns 0. The errno variable may also be set to ERANGE. If an overflow results, the pow() function returns +HUGE_VAL for a large result or -HUGE_VAL for a small result.
Example that uses pow()
This example calculates the value of 23.
#include <math.h> #include <stdio.h> int main(void) { double x, y, z; x = 2.0; y = 3.0; z = pow(x,y); printf("%lf to the power of %lf is %lf\n", x, y, z); } /***************** Output should be similar to: ***************** 2.000000 to the power of 3.000000 is 8.000000 */
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.