2 ** 256 BigInteger in javascript

独自空忆成欢 提交于 2019-12-12 04:33:08

问题


Which will normally result in 1.157920892373162e+77 ,but what I want is the accurate number of 2 ** 256 like 1157920892731685487456125.....

I has try big-integer and math.js but both can't show all of the number after calculate.


回答1:


Works fine using big-integer:

const bigInt = require('big-integer');
let value    = bigInt(2).pow(256);

console.log(value.toString());
// 115792089237316195423570985008687907853269984665640564039457584007913129639936


来源:https://stackoverflow.com/questions/45502194/2-256-biginteger-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!