当前位置:网站首页>Ceil, floor and round functions
Ceil, floor and round functions
2022-06-12 09:07:00 【Record dada I】
C Three rounding functions commonly used in :ceil、floor、round.
The header file :#include<math.h>
ceil:
To round up , such as 5.1, After rounding is 6, namely 5<x<=6 , After rounding, it is 6.
usage :
Used in assignment
double x=5.1;
double c=ceil(x);
Or use in operation :
if(c<ceil(x))
{
}
floor:
Indicates rounding down , such as 5.1, After rounding is 5, namely 5<=x<6 , After rounding, it is 5.
Same as above .
round:
Indicates rounding operation , The same as rounding in mathematics ,eg: 5.4=5,5.6=6.
Same as above .
Other rounding techniques :
1.
double x;
int n;
n = int(x+0.5);
2. The rounding of half in an operation
int x;
x=x/2+x%2;
notes : When used ceil,floor,round Function time , The numeric type is double or float Floating point type , use int Type will automatically ignore the number after the decimal point , This will cause the function to fail ( Non grammatical error ),int Type operation is automatically rounded down .
边栏推荐
- Flink CheckPoint : Exceeded checkpoint tolerable failure threshold
- (js)三位用逗号隔开,保留两位小数(or 四舍五入取整)
- UMI packaging and subcontracting, and compressing to gzip
- MFS explanation (IV) -- MFS management server installation and configuration
- 【字符集六】宽字符串和多字节字符互转
- Gets the number of occurrences of a character in a string
- Chapter 7 - more flexible location of memory addresses
- Introduction to Chang'an chain node certificate, role and authority management
- (十五) TweenRunner
- 清华大学数据挖掘笔记(一)
猜你喜欢

torch. logical_ And() method

【字符集八】char8_t、char16_t、char32_t、wchar、char

Can you migrate backwards before the first migration in the south- Can you migrate backwards to before the first migration in South?
![[character set 8] char8_ t、char16_ t、char32_ t、wchar、char](/img/ef/e57fb345b36c84d3585fca0568b0ee.png)
[character set 8] char8_ t、char16_ t、char32_ t、wchar、char

Background position - mixed units

List < string > sort

2022 safety officer-c certificate special operation certificate examination question bank and simulation examination

Priority issues

Node sample background setup

mySql学习记录——二、mySql建表命令
随机推荐
剑指 Offer II 016. 不含重复字符的最长子字符串-滑动窗口
Visualization of two-dimensional feature logistic regression prediction results
2022 safety officer-c certificate special operation certificate examination question bank and simulation examination
Exists usage in SQL
Unittest test framework
抓取屏幕与毛玻璃效果
Latex common symbols summary
top命令含义
Detailed explanation of iSCSI (V) -- actual operation of iSCSI client configuration
【字符集九】gbk拷贝到Unicode会乱码?
[computer use] how to change a computer disk into a mobile disk?
Analysis of 43 cases of MATLAB neural network: Chapter 7 regression of RBF Network -- Realization of nonlinear function regression
Implementing architecture caching in MySQL under redis server environment
更改tabledata列名
Gets the number of occurrences of a character in a string
EIP-1559
MFS详解(四)——MFS管理服务器安装与配置
(js)三位用逗号隔开,保留两位小数(or 四舍五入取整)
Can you migrate backwards before the first migration in the south- Can you migrate backwards to before the first migration in South?
Top command meaning