fabs()这个函数是做什么用的,请详细说明

ywchen2000 2002-11-14 06:22:45
fabs()这个函数是做什么用的,请详细说明
...全文
2235 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
winco 2002-11-14
  • 打赏
  • 举报
回复
程序员刘帅 2002-11-14
  • 打赏
  • 举报
回复
fabs
Calculates the absolute value of the floating-point argument.

double fabs( double x );

Function Required Header Compatibility
fabs <math.h> ANSI, Win 95, Win NT


For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version


Return Value

fabs returns the absolute value of its argument. There is no error return.

Parameter

x

Floating-point value

Example

/* ABS.C: This program computes and displays
* the absolute values of several numbers.
*/

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

void main( void )
{
int ix = -4, iy;
long lx = -41567L, ly;
double dx = -3.141593, dy;

iy = abs( ix );
printf( "The absolute value of %d is %d\n", ix, iy);

ly = labs( lx );
printf( "The absolute value of %ld is %ld\n", lx, ly);

dy = fabs( dx );
printf( "The absolute value of %f is %f\n", dx, dy );
}


Output

The absolute value of -4 is 4
The absolute value of -41567 is 41567
The absolute value of -3.141593 is 3.141593


riverboat 2002-11-14
  • 打赏
  • 举报
回复
abs家族函数:
用于取得某种类型数的绝对值(或复数取模)
定义于 <MATH.H, STDLIB.H, COMPLEX.H>

abs
real: int abs(int x);
complex: double abs(complex x);
double cabs(struct complex z);
long double cabsl(struct _complexl (z));
double fabs(double x);
long double fabsl(long double @E(x));
long int labs(long int x);
xspf 2002-11-14
  • 打赏
  • 举报
回复
fabs()求浮点数的绝对值,返回double

在C中,有abs(),labs(),fabs()分别计算int ,long ,double 类型的绝对值;
而在C++中,abs()已被重载,可适用于各种类型

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧