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