1

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.

3
  • why negative? no code for you to read? Commented Aug 4, 2017 at 8:47
  • Yes. Questions about code not working should have code in them, ideally a re-create. Commented Aug 4, 2017 at 9:15
  • Paste 2 ** 256 in chrome console isn't it? And it's not about code not working. Commented Aug 4, 2017 at 9:39

1 Answer 1

3

Works fine using big-integer:

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

console.log(value.toString());
// 115792089237316195423570985008687907853269984665640564039457584007913129639936
Sign up to request clarification or add additional context in comments.

1 Comment

With large numbers like that, you can't use the built-in JS methods for calculation (which are limited to what JS itself is limited to), you have to use the methods that big-integer provides.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.