2.1 2.6 -2.1 -2.6
floor : 不大于自变量的最大整数 2 2 -3 -3
ceil :不小于自变量的最大整数 3 3 -2 -2
round:四舍五入到最邻近的整数 2 3 -2 -3
floor : 不大于自变量的最大整数 2 2 -3 -3
ceil :不小于自变量的最大整数 3 3 -2 -2
round:四舍五入到最邻近的整数 2 3 -2 -3
round(num,num_dight) 把num精确到num_dight位数
floor(),ceil() 需包含头文件<math.h>
C++中没有直接的round函数 需自己建立
double round(double r)
{
return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}
{
return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}
原文链接: https://www.cnblogs.com/zhuruibi/p/8972605.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/273056
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!