C ++ fabs()函数 (C++ fabs() function)

fabs() function is a library function of cmath header, it is used to find the absolute value of the given number, it accepts a number and returns absolute value.

fabs()函数cmath标头的库函数,用于查找给定数字的绝对值,它接受一个数字并返回绝对值。

Note: abs() function of cmath header can also be used for the same purpose.

注意: cmath标头的abs()函数也可以用于相同的目的。

Syntax of fabs() function:

fabs()函数的语法:

    fabs(x);

Parameter(s): x – is the number whose absolute value is returned.

参数: x –是返回其绝对值的数字。

Return value: double – it returns double value that is the absolute value of x.

返回值: double-返回double值,它是x的绝对值。

Example:

例:

    Input:
float x = -1012.232;
Function call:
fabs(x);
Output:
1012.232

C ++代码演示fabs()函数的示例 (C++ code to demonstrate the example of fabs() function)

// C++ code to demonstrate the example of
// fabs() function
#include <iostream>
#include <cmath>
using namespace std;
// main() section
int main()
{float x;
float result;
x = -10;
cout<<"fabs("<<x<<"): "<<fabs(x)<<endl;
x = -1012.232;
cout<<"fabs("<<x<<"): "<<fabs(x)<<endl;
x = 1012.232;
cout<<"fabs("<<x<<"): "<<fabs(x)<<endl;
x = -.908;
cout<<"fabs("<<x<<"): "<<fabs(x)<<endl;
return 0;
}

Output

输出量

fabs(-10): 10
fabs(-1012.23): 1012.23
fabs(1012.23): 1012.23
fabs(-0.908): 0.908

翻译自: https://www.includehelp.com/cpp-tutorial/fabs-function-with-example.aspx

fabs()函数以及C ++中的示例相关推荐

  1. python 功能键ord_ord()函数以及Python中的示例

    Python ord() 功能 ord()函数是Python中的一个库函数,它用于从给定的字符值中获取数字值,它接受一个字符并返回一个整数,即用于将字符转换为整数,即用于获取a的ASCII值.给定的字 ...

  2. python中pow函数_pow()函数以及Python中的示例

    python中pow函数 Python pow()函数 (Python pow() function) pow() function is a library function in Python, ...

  3. to_number用法示例_Number()函数以及JavaScript中的示例

    to_number用法示例 Number()函数 (Number() function) Number() function is a predefined global function in Ja ...

  4. eval 函数 代替函数_eval()函数以及JavaScript中的示例

    eval 函数 代替函数 eval()函数 (eval() function) eval() function is a predefined global function in JavaScrip ...

  5. python中len函数_len()函数以及Python中的示例

    python中len函数 Python len()函数 (Python len() function) len() function is a library function in Python, ...

  6. java中isnan函数_isNaN()函数以及JavaScript中的示例

    java中isnan函数 Prerequisite: NaN property in JavaScript 先决条件: JavaScript中的NaN属性 isNaN()函数 (isNaN() fun ...

  7. c语言 函数的参数传递示例_isgreater()函数以及C ++中的示例

    c语言 函数的参数传递示例 C ++ isgreater()函数 (C++ isgreater() function) isgreater() function is a library functi ...

  8. fmax()函数以及C ++中的示例

    C ++ fmax()函数 (C++ fmax() function) fmax() function is a library function of cmath header, it is use ...

  9. isless()函数与C ++中的示例

    C ++ isless()函数 (C++ isless() function) isless() function is a library function of cmath header, it ...

最新文章

  1. 详解原生AJAX请求demo(兼容IE5/6)
  2. memory matlab,memory – 在MATLAB中处理大量结构
  3. python基础(二)字符串內建函数详解
  4. [Swift]LeetCode498. 对角线遍历 | Diagonal Traverse
  5. html 使用button调用函数
  6. MSE和Cross-entropy梯度更新比较
  7. a4如何打印双面小册子_怎样将十几几十页的长文件文档打印成A4纸对折的小册子?...
  8. python3解析库BeautifulSoup4
  9. 查找你的幸运守护精灵
  10. 非北京户口的驾照到期换证小攻略(仅供参考)
  11. java阿里云文本反垃圾sdk调用详解
  12. 【学习打卡02】可解释机器学习笔记之ZFNet
  13. 关于硬盘不可不知的基础知识-硬盘开盘修复
  14. Hive数据库创建表
  15. 免费的pdf转word工具
  16. 编码过程中单词常用的缩写方式(转载)
  17. 大学计算机原理知识点,四川大学计算机组成原理知识点
  18. 梳理公司的组织架构 --- 组合模式
  19. HEVC-I帧中CU,TU,PU之间的关系
  20. 现在不止是开淘宝店赚钱,淘宝周边产业也赚钱

热门文章

  1. 学者解读希腊危机:强大欧盟难有强大领导力
  2. 讨人喜欢的26个原则
  3. 【八大排序(五)】快排进阶篇-挖坑法+前后指针法
  4. 基于JSP的在线书店系统
  5. TD—LTE小区切换技术分析和建议
  6. appstore关键词搜索app——itunes接口
  7. 使用一个月后,苹果 M1 MacBook Pro 深度体验报告
  8. 问题随记 —— 在 edge 上看视频会绿屏
  9. AcFun API 收集
  10. C++COLORREF与字符串互转