pow ()- Power ® の計算
形式
#include <math.h>
double pow(double x, double y);言語レベル
ANSI
スレッド・セーフ
はい
説明
pow() 関数は、 x の値を yの累乗で計算します。
戻り値
y が 0の場合、 pow() 関数は値 1 を戻します。 x が 0 で、 y が負の場合、 pow() 関数は errno を EDOM に設定し、 0を戻します。 x と y の両方が 0の場合、または x が負で y が整数でない場合、 pow() 関数は errno を EDOMに設定し、 0を戻します。 errno 変数は、ERANGE に設定することもできます。 オーバーフローが発生すると、 pow() 関数は、大きな結果の場合は + HUGE_VAL を、小さな結果の場合は -HUGE_VAL を戻します。
例
この例では、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
*/