int roundedValueA = qRound(valueA);
// roundedValueA = 42949672960
int roundedValueB = qRound(valueB);
// roundedValueB = 42949672961
int qRound ( qreal value )
四舍五入返回最近的整数值,示例:
qreal valueA = 2.3; qreal valueB = 2.7;
int roundedValueA = qRound(valueA);
// roundedValueA = 2
int roundedValueB = qRound(valueB);
// roundedValueB = 3
上面四舍五入的进位基数是1,如果基数不等于1,就要自己写Round函数。
int getRoung(int iValue, int iBase)
{
int iFactor,int iMod;
iFactor = iValue / iBase;
iMod = iValue % iBase;
iFactor=(iMod*2>iBase)?(iFactor+1):iFactor;
int iRtn=iFactor*iBase;
return iRtn;
}