整数舍入函数宏
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了整数舍入函数宏相关的知识,希望对你有一定的参考价值。
#include "math.h" #define round(x) (x<0?ceil((x)-0.5):floor((x)+0.5)) //or #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
以上是关于整数舍入函数宏的主要内容,如果未能解决你的问题,请参考以下文章
Javascript Math ceil()floor()round()三个函数的区别