floor、ceil、round、fix
floor、ceil、round、fix
作用: 对double、float数据取整;
头文件: math.h
floor(x):不大于x的最大整数;
ceil(x):不小于x的最小整数;
round(x):四舍五入到最近整数;
fix(x):截断取整函数。
例
floor(-2.1) = -3;
floor(2.1) = 2;
ceil(-2.1) = -2;
ceil(2.1) = 3;
round(2.1) = 2;
round(2.6) = 3;
round(-2.1) = -2;
round(-2.6) = -3;
fix(-2.1) = -2;
fix(2.1) = 2
fix(-2.6) = -2;
fix(2.6) = 2
posted on 2016-03-06 09:53 silentteen 阅读(244) 评论(0) 收藏 举报
浙公网安备 33010602011771号