Skip to content

Commit 2bd0cbb

Browse files
committed
edit docs/number/Math.trunc()
1 parent bf3d165 commit 2bd0cbb

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docs/number.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,22 @@ Number.isSafeInteger(outside) // false
6868

6969
## Math对象的扩展
7070

71-
ES6在Math对象上提供了更多的数学方法。
71+
**(1)Math.trunc()**
72+
73+
Math.trunc方法用于去除一个数的小数部分,返回整数部分。
74+
75+
```javascript
76+
77+
Math.trunc(4.1) // 4
78+
Math.trunc(4.9) // 4
79+
Math.trunc(-4.1) // -4
80+
Math.trunc(-4.9) // -4
81+
82+
```
83+
84+
**(2)数学方法**
85+
86+
ES6在Math对象上还提供了许多新的数学方法。
7287

7388
- Math.acosh(x) 返回x的反双曲余弦(inverse hyperbolic cosine)
7489
- Math.asinh(x) 返回x的反双曲正弦(inverse hyperbolic sine)
@@ -85,4 +100,3 @@ ES6在Math对象上提供了更多的数学方法。
85100
- Math.log2(x) 返回以2为底的x的对数
86101
- Math.sign(x) 如果x为负返回-1,x为0返回0,x为正返回1
87102
- Math.tanh(x) 返回x的双曲正切(hyperbolic tangent)
88-
- Math.trunc(x) 移除一个浮点数的小数位,返回一个整数

0 commit comments

Comments
 (0)