天井関数を計算します.
Math.ceil(x)
ceilメソッドはx以上の最小の整数を返します.
以下にceilメソッドを使用したサンプルコードを示します.
<html>
<head>
<title>ceilメソッドのサンプルコード</title>
</head>
<body>
<script type="text/javascript" language="javascript">
document.write(Math.ceil(1.0001) + "<br />");
document.write(Math.ceil(-1.0001) + "<br />");
document.write(Math.ceil(1.5000) + "<br />");
document.write(Math.ceil(-1.5000) + "<br />");
document.write(Math.ceil(0) + "<br />");
</script>
</body>
</html>
サンプルコードの実行結果は以下のようになります.
2 -1 2 -1 0
スポンサード リンク