JS对象 向上取整ceil() ceil() 方法可对一个数进行向上取整。 语法: Math.ceil(x) 注意:它返回的是大于或等于x,并且与x最接近的整数。
向上取整ceil()
任务
在右边编辑器中补充代码,在script标签内,使用ceil()方法,计算3.3、-0.1、-9.9、8.9值。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
document.write(Math.ceil(3.3)+"<br/>");
document.write(Math.ceil(-0.1)+"<br/>");
document.write(Math.ceil(-9.9)+"<br/>");
document.write(Math.ceil(8.9));
</script>
</head>
<body>
</body>
</html>


浙公网安备 33010602011771号