1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-28 21:32:20 +00:00

edit docs/number/Math.trunc()

This commit is contained in:
ruanyf 2014-05-29 01:06:20 +08:00
parent bf3d1658a4
commit 2bd0cbbedb

View File

@ -68,7 +68,22 @@ Number.isSafeInteger(outside) // false
## Math对象的扩展
ES6在Math对象上提供了更多的数学方法。
**1Math.trunc()**
Math.trunc方法用于去除一个数的小数部分返回整数部分。
```javascript
Math.trunc(4.1) // 4
Math.trunc(4.9) // 4
Math.trunc(-4.1) // -4
Math.trunc(-4.9) // -4
```
**2数学方法**
ES6在Math对象上还提供了许多新的数学方法。
- Math.acosh(x) 返回x的反双曲余弦inverse hyperbolic cosine
- Math.asinh(x) 返回x的反双曲正弦inverse hyperbolic sine
@ -85,4 +100,3 @@ ES6在Math对象上提供了更多的数学方法。
- Math.log2(x) 返回以2为底的x的对数
- Math.sign(x) 如果x为负返回-1x为0返回0x为正返回1
- Math.tanh(x) 返回x的双曲正切hyperbolic tangent
- Math.trunc(x) 移除一个浮点数的小数位,返回一个整数