C語言數學函式ceil簡介
函式名:ceil用法:doubleceil(doublex);
功能:返回大於或者等於指定表達式的最小整數
頭檔案:math.h
ceil函式的使用
ceil函式的作用是求不小於給定實數的最小整數。ceil(2)=ceil(1.2)=cei(1.5)=2.00
程式例
#include<stdio.h>#include<math.h>
intmain(void)
{
doublenumber=123.54;
doubledown,up;
down=floor(number);
up=ceil(number);
printf("originalnumber%5.2lf\n",number);
printf("numberroundeddown%5.2lf\n",down);
printf("numberroundedup%5.2lf\n",up);
return0;
}
運行結果:
originalnumber123.54
numberroundeddown123.00
numberroundedup124.00