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