-1

I tried looking on the forum on how to handle digits larger than 16. So far I found this post:

How can I handle numbers bigger than 17-digits in Firefox/IE7?

which does not provide a solution but only recommends to do some tricks to handle the operations.

I also looked online for libraries that could cope with this, such as this library, which is again limited by 15 digits.

http://mikemcl.github.io/decimal.js/#precision

What other ways are there to handle arithmetic operations for numbers with digits larger than 15?

Community
  • 1
  • 1
WJA
  • 6,676
  • 16
  • 85
  • 152
  • "*digits larger than 16*" sounds like you aren't satisfied with hexadecimal numbers and want a higher base :-) – Bergi Jun 23 '15 at 15:11
  • Look harder, and you'll find [Javascript summing large integers](http://stackoverflow.com/questions/4557509), [What is the standard solution in Javascript for handling big numbers](http://stackoverflow.com/questions/3072307), [Javascript long integer](http://stackoverflow.com/questions/17320706) and [What JavaScript library can I use to manipulate big integers?](http://stackoverflow.com/questions/14531137) And more! – Mogsdad Jun 23 '15 at 15:24

1 Answers1

2

Try looking for decimal math and arbitrary precision libraries.

"Decimal math" means it operates on decimal digits instead of binary digits.

Decimal floating point (DFP) arithmetic refers to both a representation and operations on decimal floating point numbers. Working directly with decimal (base 10) fractions can avoid the rounding errors that otherwise typically occur when converting between decimal fractions (common in human-entered data, such as measurements or financial information) and binary (base 2) fractions.

Arbitrary precision means without hard limits on number of digits.

In computer science, arbitrary-precision arithmetic, also called bignum arithmetic, multiple precision arithmetic, or sometimes infinite-precision arithmetic, indicates that calculations are performed on numbers whose digits of precision are limited only by the available memory of the host system. This contrasts with the faster fixed-precision arithmetic found in most arithmetic logic unit (ALU) hardware, which typically offers between 8 and 64 bits of precision.

Is there a decimal math library for JavaScript? might be a good starting point.

Community
  • 1
  • 1
Mike Samuel
  • 118,113
  • 30
  • 216
  • 245