pow ()- Power ® の計算

形式

#include <math.h>
double pow(double x, double y);

言語レベル

ANSI

スレッド・セーフ

はい

説明

pow() 関数は、 x の値を yの累乗で計算します。

戻り値

y0の場合、 pow() 関数は値 1 を戻します。 x0 で、 y が負の場合、 pow() 関数は errnoEDOM に設定し、 0を戻します。 xy の両方が 0の場合、または x が負で y が整数でない場合、 pow() 関数は errnoEDOMに設定し、 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
*/

関連情報