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://codercto.com/courses/l/17.html

查看所有标签

Flow-Based Programming (2nd Edition)

Flow-Based Programming (2nd Edition)

CreateSpace / 2010-5-14 / $69.95

Written by a pioneer in the field, this is a thorough guide to the cost- and time-saving advantages of Flow-Based Programming. It explains the theoretical underpinnings and application of this program......一起来看看 《Flow-Based Programming (2nd Edition)》 这本书的介绍吧!

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

在线XML、JSON转换工具

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

html转js在线工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具