国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JavaScipt中的Math.ceil() 、Math.floor() 、Math.round() 三個函數的理解

2019-11-21 00:32:10
字體:
來源:轉載
供稿:網友

首先還是看看JavaScript: The Definitive Guide, 4th Edition中對三個函數的定義。

Math.ceil(): round a number up

Arguments: Any numeric value or expression

Returns: The closest integer greater than or equal to x.

-----------------------------------------------------------------------------------------------

Math.floor(): round a number down

Arguments: Any numeric value or expression

Returns: The closest integer less than or equal to x.

-----------------------------------------------------------------------------------------------

Math.round(): round to the nearest integer

Arguments: Any number.

Returns: The integer closest to x.

 

以前一直會三個函數的使用產生混淆,現在通過對三個函數的原型定義的理解,其實很容易記住三個函數。

現在做一個總結:

1. Math.ceil()用作向上取整。

2. Math.floor()用作向下取整。

3. Math.round() 我們數學中常用到的四舍五入取整。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 咸丰县| 辽中县| 丰都县| 南城县| 济阳县| 井冈山市| 沧州市| 秭归县| 睢宁县| 滦平县| 温宿县| 呈贡县| 根河市| 顺平县| 株洲市| 崇信县| 长海县| 温宿县| 英德市| 昭通市| 光山县| 泊头市| 龙泉市| 东乡族自治县| 山东省| 新乡市| 雷州市| 花莲县| 伊春市| 宁河县| 东丰县| 遂宁市| 凤凰县| 泾阳县| 天柱县| 子洲县| 理塘县| 宕昌县| 池州市| 柳州市| 绥江县|