C 库函数 - fabs()

C 语言教程 · 2019-02-23 10:29:13

描述

C 库函数 double fabs(double x) 返回 x 的绝对值。

声明

下面是 fabs() 函数的声明。

double fabs(double x)

参数

  • x -- 浮点值。

返回值

该函数返回 x 的绝对值。

实例

下面的实例演示了 fabs() 函数的用法。

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

int main ()
{
   int a, b;
   a = 1234;
   b = -344;
  
   printf("%d 的绝对值是 %lf\n", a, fabs(a));
   printf("%d 的绝对值是 %lf\n", b, fabs(b));
   
   return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

1234 的绝对值是 1234.000000
-344 的绝对值是 344.000000

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

Twenty Lectures on Algorithmic Game Theory

Twenty Lectures on Algorithmic Game Theory

Tim Roughgarden / Cambridge University Press / 2016-8-31 / USD 34.99

Computer science and economics have engaged in a lively interaction over the past fifteen years, resulting in the new field of algorithmic game theory. Many problems that are central to modern compute......一起来看看 《Twenty Lectures on Algorithmic Game Theory》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具