欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript Math.floor方法(對數(shù)值向下取整)

 更新時間:2015年01月09日 10:51:22   投稿:mdxy-dxy  
這篇文章主要介紹了Math.floor 方法用于對數(shù)值向下取整,即得到小于或等于該數(shù)值的最大整數(shù),需要的朋友可以參考下

JavaScript Math.floor 方法
Math.floor 方法用于對數(shù)值向下取整,即得到小于或等于該數(shù)值的最大整數(shù)。語法如下:

Math.floor(x)
參數(shù)說明:

參數(shù) 說明
x 必需。必須是一個數(shù)值。

提示:該方法與 Math.ceil 方法正好相反。

Math.floor 方法實例

<script language="JavaScript">
document.write( Math.floor(0.35) + "<br />" );
document.write( Math.floor(10) + "<br />" );
document.write( Math.floor(-10) + "<br />" );
document.write( Math.floor(-10.1) );
</script>

運行該例子,輸出:

0
10
-10
-11

Math.floor 可能不準的問題

如果參數(shù) x 是一個涉及浮點數(shù)的表達式,那么由于計算機的固有原理,可能導致表達式應用 Math.floor 方法后結(jié)果不準確(不符合常理),具體參考《Math.ceil 方法》一文中的相關(guān)描述。

相關(guān)文章

最新評論