整数舍入函数宏

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了整数舍入函数宏相关的知识,希望对你有一定的参考价值。

  1. #include "math.h"
  2.  
  3. #define round(x) (x<0?ceil((x)-0.5):floor((x)+0.5))
  4. //or
  5. #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

以上是关于整数舍入函数宏的主要内容,如果未能解决你的问题,请参考以下文章

常用函数

Math三个函数

Javascript Math ceil()floor()round()三个函数的区别

Math.round() 函数返回一个数字四舍五入后最接近的整数。

区分舍入函数fix/round/ceil/floor

php floor()函数 语法