floor() 方法可對一個數(shù)進(jìn)行向下取整。
語法:
Math.floor(x)
參數(shù)說明:
注意:返回的是小于或等于x,并且與 x 最接近的整數(shù)。
我們將在不同的數(shù)字上使用 floor() 方法,代碼如下:
<script type="text/javascript"> document.write(Math.floor(0.8)+ "<br>") document.write(Math.floor(6.3)+ "<br>") document.write(Math.floor(5)+ "<br>") document.write(Math.floor(3.5)+ "<br>") document.write(Math.floor(-5.1)+ "<br>") document.write(Math.floor(-5.9)) </script>
運(yùn)行結(jié)果:
0 6 5 3 -6 -6
補(bǔ)充右邊編輯器在script標(biāo)簽內(nèi),使用floor()方法,計算3.3、-0.1、-9.9、8.9值。
floor()向下取整計算,它返回的是大于或等于的值
請驗證,完成請求
由于請求次數(shù)過多,請先驗證,完成再次請求
打開微信掃碼自動綁定
綁定后可得到
使用 Ctrl+D 可將課程添加到書簽
舉報