Friday, May 17, 2024
43
rated 0 times [  48] [ 5]  / answers: 1 / hits: 53124  / 14 Years ago, fri, june 18, 2010, 12:00:00

Is there a bignum built into JavaScript or browsers?


The alternate is loading an external library like


<script type="text/javascript" src="the_bignum_library.js"></script>

but that seems slow and may trigger a security warning.


I've considered basing my own off of http://github.com/silentmatt/javascript-biginteger or http://www.mainebrook.com/john/fun/euler.html. Alternately, is the solution to call into a Java bignum library such as apfloat?


More From » floating-accuracy

 Answers
36

Update(2019-08-19): BigInt is now part of Firefox and Chrome; you no longer need a library:





const bigInt1 = 1111111111111111111111111111111n;
const bigInt2 = BigInt(1111111111111111111111111111111)
console.log((bigInt1 + bigInt2)+)





Original answer:



If you need arbitrary-precision decimal numbers, use Javascript-bignum, as it is correct and fast.


[#96456] Tuesday, June 15, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tayla

Total Points: 681
Total Questions: 102
Total Answers: 108

Location: Marshall Islands
Member since Tue, Sep 21, 2021
3 Years ago
tayla questions
Fri, Mar 5, 21, 00:00, 3 Years ago
Wed, Oct 28, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
;