如何在JavaScript中获取小于或等于数字的最大整数?
要获取小于或等于数字的最大整数,请使用JavaScript中的Math.floor()方法。
示例
您可以尝试运行以下代码以获取小于或等于数字的最大整数-
<html>
<head>
<title>JavaScript Math floor() Method</title>
</head>
<body>
<script>
var value = Math.floor(50.3);
document.write("First Value : " + value );
var value = Math.floor(20.7);
document.write("<br />Second Value : " + value );
var value = Math.floor(-5.8);
document.write("<br />Third Value : " + value );
var value = Math.floor(-3.1);
document.write("<br />Fourth Value : " + value );
</script>
</body>
</html>热门推荐
10 水晶婚夫妻祝福语简短
11 幸福卡片祝福语英文简短
12 给男生的简短祝福语
13 关于扬州的祝福语简短
14 小年好的祝福语简短
15 发给导师的祝福语简短
16 祝女人美丽祝福语简短
17 忙碌生活祝福语简短英文
18 鱼的内涵简短祝福语