如何在十进制中获得 2 的大幂或如何将大指数值转换为十进制值。
我想要 2 的十进制 128 次方,而不是我现在所做的指数
tofixed(+exponent)
Run Code Online (Sandbox Code Playgroud)
这再次给了我相同的价值。
var num = Math.pow(2, 128);
Run Code Online (Sandbox Code Playgroud)
实际结果 = 3.402823669209385e+38 预期一些十进制值而不是指数值。
BigInt如果实施,您可以使用。
var num = BigInt(2) ** BigInt(128);
console.log(num.toString());
console.log(BigInt(2 ** 128).toString());Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
988 次 |
| 最近记录: |