fabs ()- 计算浮点绝对值

格式

#include <math.h>
double fabs(double x);

语言级别

ANSI

线程安全

描述

fabs() 函数计算浮点自变量 x的绝对值。

返回值

fabs() 函数返回绝对值。 没有错误返回值。

示例

此示例将 y 计算为 x的绝对值:
#include <math.h>
#include <stdio.h>
 
int main(void)
{
   double x, y;
 
   x = -5.6798;
   y = fabs(x);
 
   printf("fabs( %lf ) = %lf\n", x, y);
}
 
/*******************  Output should be similar to:  ***************
 
fabs( -5.679800 ) = 5.679800
*/

相关信息