iOS 取四舍五入取平均值

来源:互联网 发布:来自故宫的礼物 淘宝 编辑:程序博客网 时间:2024/06/04 19:56

C语言中用一个 round()函数可以进行四舍五入

round(double),需要传入double类型参数。然后再用 NSInteger去接收就可以了。

NSInteger rating = round(11.0 / 2.0);

输出结果为 6