- abs()是对整数取绝对值, 而fabs()是对浮点数取绝对值。
- 函数原型:
int abs(int x)
double fabs(double x)
- 头文件
abs(): #include <stdlib.h>
fabs(): #include <math.h>
- 两者在只#include时都可以使用
int abs(int x)
double fabs(double x)
abs(): #include <stdlib.h>
fabs(): #include <math.h>