#include <math.h>
double floor( double arg );
函数返回参数不大于 arg 的最大整数。
#include <stdio.h> #include <math.h> int main(void) { double number = 123.54; double down, up; down = floor(number); up = ceil(number); printf("original number %10.2lf\n", number); printf("number rounded down %10.2lf\n", down); printf("number rounded up %10.2lf\n", up); return 0; }
输出结果:
original number 123.54 number rounded down 123.00 number rounded up 124.00