C/C++程序实例
#include<stdio.h>
#include<math.h>
intmain(void)
{
double number=123.45;
double down,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;
}
javascript实例
<html> <body> <scripttype="text/javascript"> document.write(Math.ceil(0.60)+"<br/>") document.write(Math.ceil(0.40)+"<br/>") document.write(Math.ceil(5)+"<br/>") document.write(Math.ceil(5.1)+"<br/>") document.write(Math.ceil(-5.1)+"<br/>") document.write(Math.ceil(-5.9)) </script> </body> </html>
php程序实例
<?php
echo ceil(4.3);//5
echo ceil(9.999);//10
?>