機能 |
xのy乗(xy)を計算する事を表す。 xが有限な負数かつyが整数値でない場合は定義域エラー(EDOM)が発生する。 xが0かつyが0以下の場合は定義域エラー(EDOM)または値域エラー(ERANGE)が発生することがある。 |
||||
---|---|---|---|---|---|
定義 |
#include <math.h> double pow ( double x, double y ); float pow ( float x, float y ); long double pow ( long double x, long double y ); ※C99規格では以下の定義となる double pow ( double x, double y ); float powf ( float x, float y ); long double powl ( long double x, long double y ); |
||||
引数 |
|
||||
戻り値 | 計算結果を返す。 | ||||
実装例 |
#include <math.h> #include <stdio.h> int main(void) { double a = 2.0; double b = 3.0; printf("pow(%f, %f) = %f\n", a, b, pow(a,b) ); /* a^b */ return 0; } |
||||
実行結果 |
pow(2.000000, 3.000000) = 8.000000 |
pow()