c语言 函数的参数传递示例_C ++中带有示例的nearint()函数
c语言 函数的参数传递示例
C ++附近的int()函数 (C++ nearbyint() function)
nearbyint() function is a library function of cmath header, it is used to round the given value to an integral value based on the specified direction by fegetround() function. It accepts a value and returns the rounded integral value.
nearint()函数是cmath标头的库函数,用于通过fegetround()函数根据指定方向将给定值舍入为整数值。 它接受一个值并返回四舍五入的整数值。
Syntax of nearbyint() function:
附近的int()函数的语法:
C++11:
C ++ 11:
double nearbyint (double x);
float nearbyint (float x);
long double nearbyint (long double x);
double nearbyint (T x);
Parameter(s):
参数:
x – represents the value to round.
x –表示要取整的值。
Return value:
返回值:
It returns value rounded to nearby integral.
它返回四舍五入到附近整数的值。
Example:
例:
Input:
double x = 123.4;
Function call:
nearbyint(x);
Output:
123
Input:
double x = 123.5;
Function call:
nearbyint(x);
Output:
124
C ++代码来演示Nearestint()函数的示例 (C++ code to demonstrate the example of nearbyint() function)
// C++ code to demonstrate the example of
// nearbyint() function
#include <iostream>
#include <cmath>
#include <fenv.h> // for fegetround()
using namespace std;
int main()
{
double x = 0.0;
cout << "Specified rounding is: ";
switch (fegetround()) {
case FE_DOWNWARD:
cout << "Downward" << endl;
break;
case FE_TONEAREST:
cout << "To-nearest" << endl;
break;
case FE_TOWARDZERO:
cout << "Toward-zero" << endl;
break;
case FE_UPWARD:
cout << "Upward" << endl;
break;
default:
cout << "Unknown" << endl;
}
x = 123.4;
cout << "nearbyint(" << x << "): " << nearbyint(x) << endl;
x = 123.5;
cout << "nearbyint(" << x << "): " << nearbyint(x) << endl;
x = 123.6;
cout << "nearbyint(" << x << "): " << nearbyint(x) << endl;
x = -123.4;
cout << "nearbyint(" << x << "): " << nearbyint(x) << endl;
x = -123.5;
cout << "nearbyint(" << x << "): " << nearbyint(x) << endl;
x = -123.6;
cout << "nearbyint(" << x << "): " << nearbyint(x) << endl;
return 0;
}
Output
输出量
Specified rounding is: To-nearest
nearbyint(123.4): 123
nearbyint(123.5): 124
nearbyint(123.6): 124
nearbyint(-123.4): -123
nearbyint(-123.5): -124
nearbyint(-123.6): -124
Reference: C++ nearbyint() function
参考: C ++附近的int()函数
翻译自: https://www.includehelp.com/cpp-tutorial/nearbyint-function-with-example.aspx
c语言 函数的参数传递示例
c语言 函数的参数传递示例_C ++中带有示例的nearint()函数相关推荐
- c++ cdi+示例_C ++中带有示例的本地类
c++ cdi+示例 C ++中的本地类 (Local Class in C++) In C++, generally a class is declared outside of the main( ...
- python 示例_Python中带有示例的关键字除外
python 示例 Python关键字除外 (Python except keyword) except is a keyword (case-sensitive) in python, it is ...
- c语言atoll函数怎么用_C ++中带有示例的atoll()函数
c语言atoll函数怎么用 C ++ Atoll()函数 (C++ atoll() function) atoll() function is a library function of cstdli ...
- nanf flash校验_C ++中带有示例的nanf()函数
nanf flash校验 C ++ Nanf()函数 (C++ nanf() function) nanf() function is a library function of cmath head ...
- c++ abort 函数_C ++中带有示例的abort()函数
c++ abort 函数 C ++ abort()函数 (C++ abort() function) abort() function is a library function of cstdlib ...
- python 示例_Python中带有示例的class关键字
python 示例 Python类关键字 (Python class keyword) class is a keyword (case-sensitive) in python, it is use ...
- c语言中swap函数_C ++中的swap()函数
c语言中swap函数 介绍 (Introduction) In this tutorial, we are going to learn the swap() function in C++ prog ...
- c语言 函数的参数传递示例_C语言中带有示例的remove()函数
c语言 函数的参数传递示例 C语言中的remove()函数 (remove() function in C) The remove() function is defined in the <s ...
- R语言笔记6:在R中写一些简单的函数、functions基础和作用域
R语言基础系列: 1数据类型(向量.数组.矩阵. 列表和数据框) 2读写数据所需的主要函数.与外部环境交互 3数据筛选--提取对象的子集 4向量.矩阵的数学运算 5控制结构 Your first R ...
最新文章
- Visual Studio视觉编程工具(推荐四个)
- linux中yum安装splunk,Yum源搭建
- 硅谷创业公司的成长道路
- 团队开发项目-NABCD模型
- 使用 Vue + Flask 搭建单页应用
- Kafka坑 - Couldn't find leaders for Set(kafka重启)
- Linux下Gcc生成和使用静态库和动态库详解
- [转]docker入门(利用docker部署web应用)
- LeetCode 2064. 分配给商店的最多商品的最小值(二分查找)
- mysql varchar 效率_由MySQL中char和varchar效率想到的
- python多环境管理_怎样管理多个Python版本和虚拟环境
- 社保交满15年就可以停缴了吗?就可以领取养老金了吗?
- 用scikit-learn和pandas学习线性回归,XGboost算法实例,用MSE评估模型
- 在.net Core中使用StackExchange.Redis 2.0
- vue 找回密码_密码系统
- 【博客559】更出色的网络监控采集方案---Telemetry(遥测技术)
- 为什么没人再提勤劳致富了?
- GBase XDM用户管理
- 函数TEXT - 补0实现数字固定位数输出
- 三天写完毕业论文——经验分享
热门文章
- 南京高中计算机老师,南京市教育局召开中小学教师信息技术应用能力提升工程2.0市级专家组工作会议...
- ci框架 乱码 mysql_mysql容器乱码问题
- 人工蜂群算法python_改进的人工蜂群算法解决聚类问题(在Python中的分步实现)...
- Spyder 代码自动补全功能,代码提示
- innobackupex参数说明
- Kotlin入门(14)继承的那些事儿
- 10.8-全栈Java笔记:序列化/反序列化的步骤和实例
- 老男孩IT教育38期面授班 学员邢伟的决心书
- dotConnect for Oracle控件免费下载及使用方法
- 云计算的发展及应用--演讲用PPT