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

docs(number): edit Number.EPSILON #508

This commit is contained in:
ruanyf 2017-10-01 06:54:47 +08:00
parent 673440939e
commit 1459519ff0

View File

@ -198,7 +198,7 @@ Number.EPSILON.toFixed(20)
0.1 + 0.2 === 0.3 // false
```
`Number.EPSILON`可以用来设置“能够接受的误差范围”。比如,如果两个浮点数的差小于2的-50次方`Number.EPSILON * Math.pow(2, 2)`,我们就可以认为这两个浮点数相等
`Number.EPSILON`可以用来设置“能够接受的误差范围”。比如,误差范围设为2的-50次方`Number.EPSILON * Math.pow(2, 2)`),即如果两个浮点数的差小于这个值,我们就认为这两个浮点数相等。
```javascript
5.551115123125783e-17 < Number.EPSILON * Math.pow(2, 2)