Skip to content

Commit 44240a7

Browse files
committed
docs(number): fixed #1184, remove BigInt.parseInt
1 parent e1ee252 commit 44240a7

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

docs/number.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,10 @@ BigInt 继承了 Object 对象的两个实例方法。
884884

885885
- `BigInt.prototype.toLocaleString()`
886886

887-
此外,还提供了三个静态方法
887+
此外,还提供了两个静态方法
888888

889889
- `BigInt.asUintN(width, BigInt)`: 给定的 BigInt 转为 0 到 2<sup>width</sup> - 1 之间对应的值。
890890
- `BigInt.asIntN(width, BigInt)`:给定的 BigInt 转为 -2<sup>width - 1</sup> 到 2<sup>width - 1</sup> - 1 之间对应的值。
891-
- `BigInt.parseInt(string[, radix])`:近似于`Number.parseInt()`,将一个字符串转换成指定进制的 BigInt。
892891

893892
```javascript
894893
const max = 2n ** (64n - 1n) - 1n;
@@ -914,18 +913,6 @@ BigInt.asUintN(32, max) // 4294967295n
914913

915914
上面代码中,`max`是一个64位的 BigInt,如果转为32位,前面的32位都会被舍弃。
916915

917-
下面是`BigInt.parseInt()`的例子。
918-
919-
```javascript
920-
// Number.parseInt() 与 BigInt.parseInt() 的对比
921-
Number.parseInt('9007199254740993', 10)
922-
// 9007199254740992
923-
BigInt.parseInt('9007199254740993', 10)
924-
// 9007199254740993n
925-
```
926-
927-
上面代码中,由于有效数字超出了最大限度,`Number.parseInt`方法返回的结果是不精确的,而`BigInt.parseInt`方法正确返回了对应的 BigInt。
928-
929916
对于二进制数组,BigInt 新增了两个类型`BigUint64Array``BigInt64Array`,这两种数据类型返回的都是64位 BigInt。`DataView`对象的实例方法`DataView.prototype.getBigInt64()``DataView.prototype.getBigUint64()`,返回的也是 BigInt。
930917

931918
### 转换规则

0 commit comments

Comments
 (0)