Qt 取整函数 Ceil Floor Round

qCeil 向上取整

qFloor 向下取整

qRound 四舍五入

 

1     double a = 11.2;
2     double b = 11.5;
3     double c = -11.2;
4     double d = -11.5;
5  
6     qDebug() << " " << ceil(a)  << " " << ceil(b)  << " " << ceil(c)  << " " << ceil(d);
7     qDebug() << " " << floor(a) << " " << floor(b) << " " << floor(c) << " " << floor(d);
输出为:

  12  12  -11  -11

  11  11  -12  -12

 

上一篇:是不是回文字符


下一篇:Dom最常用的API