floor:向下取整
ceil:向上取整
trunc:去小数
round:四舍五入
具体实现效果如下
#include <cstdio>
#include <cmath>
using namespace std;
int main ()
{
const char * format = "%.1f \t%.1f \t%.1f \t%.1f \t%.1f\n";
printf ("value\tround\tfloor\tceil\ttrunc\n");
printf ("-----\t-----\t-----\t----\t-----\n");
printf (format, 2.3<