title: Calculate large decimals (more than 15 digits) in Javascript
body: <p>As we know, Javascript has some issues (or features) with calculating decimal numbers. For example:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>console.log(0.1 + 0.2) // 0.30000000000000004</code></pre>
  </div>
  </div>
  </p>
  
  <p>And we know that we can avoid it using different libraries (for example I use <a href="https://github.com/MikeMcl/bignumber.js/" rel="nofollow noreferrer">bignumber.js</a>), and now we have what expected:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>console.log(Number(new BigNumber(0.1).plus(0.2))); // 0.3</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/bignumber.js/6.0.0/bignumber.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>BUT</strong></p>
  
  <p>Bignumber.js has limitations:</p>
  
  <blockquote>
    <p>It accepts a value of type number (up to 15 significant digits only),
    string or BigNumber object.</p>
  </blockquote>
  
  <p>We can pass a string (it's possible), but this way we can lost some digits from the end:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>console.log(Number(new BigNumber(0.1).plus("198.43092534959501"))); // 198.530925349595, not 198.53092534959501</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/bignumber.js/6.0.0/bignumber.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Now I work with cryptocurrencies and often I deal with numbers like <code>198.43092534959501</code>, and in this case I get an error (as expected):</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>console.log(Number(new BigNumber(0.1).plus(198.43092534959501))); // error</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/bignumber.js/6.0.0/bignumber.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I know that some people uses additional multipliers, but it will not work in the case provided above. If you deal with cryptocurrencies, you know, that we actually work with non-multiplied and multiplied values (like <code>489964999999000000</code> and <code>0.489964999999</code>). But my goal for now is to sum all fiat balances for different currencies, but they have different multipliers, so I can't just sum non-multiplied values, and looks like I need to sum multiplied values somehow.</p>
  
  <p>It was a small background, but my general <strong>question is:</strong></p>
  
  <p>How to sum/multiply/etc. decimal numbers, which have more than 15 digits?</p>