トップページ > キーワード検索 > fabs()
C言語規格
C言語(その他)
プログラム
その他
fabs()
機能 実数の絶対値を計算する事を表す。
定義 #include <math.h>

double fabs ( double x );
float fabs ( float x );
long double fabs ( long double x );

※C99規格では以下の定義となる
double fabs ( double x );
float fabsf ( float x );
long double fabsl ( long double x );
引数
x計算する値
戻り値 計算結果を返す。
実装例
#include <math.h>
#include <stdio.h>

int main(void)
{
    double a = -2.0;
    
    printf("fabs(%f) = %f\n", a, fabs(a) );  /* |a| */

    return 0;
}
実行結果
fabs(-2.000000) = 2.000000





inserted by FC2 system