C / C ++ function rounding

This link: HTTPS: //blog.csdn.net/auccy/article/details/85240674
C ++ conventional rounding function has three ceil, floor, round

ceil English definition: means ceiling, the grid plate shipment; function is a function of rounding up

floor English definition: floor; ground floor; function is a function rounding down

round of English Interpretation: about; function is a function of rounding

Example:

the _tmain int (int argc, _TCHAR * the argv [])
{
a float NUM = 8.6f;
STD :: COUT NUM << << "rounded up as:" << ceil (NUM) STD :: << endl;
STD: : cout << num << "rounded down to:" << Floor (NUM) STD :: << endl;
STD :: COUT NUM << << "rounded to:" << round (num) << :: endl STD;
getchar ();
return 0;
}
The result:

 

 


----------------
Disclaimer: This article is CSDN blogger "auccy 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/auccy/article/details/85240674

Guess you like

Origin www.cnblogs.com/rb258/p/11511485.html