title: How to simulate the result of a Google Sheet multiplication formula in Javascript?
body: <p>If the value of <code>f5</code> cell in a Google Sheet is <code>1.1000</code> (a number formatted to 4 decimal places) and the value of <code>f6</code> is <code>= f5 * 1.073</code>, how can I ensure I get the same result multiplying those values in Javascript, eg:</p>
  
  <pre><code>var original_value = 1.1000;
  var derivative_value = original_value * 1.073;
  </code></pre>
  
  <p>Specifically, my question is - will the result of the Javascript multiplication (<code>derivative_value</code>) be the same as the result of the Google formula (<code>f6</code>)?  And if not, how can I make it so that it is?  </p>
  
  <p><strong>Context / What I've Tried</strong></p>
  
  <p>For context, this question is part of a larger question I am trying to resolve for which I have set up this <a href="https://jsfiddle.net/rwone/xLznk3tq" rel="nofollow noreferrer">JSFiddle</a>.   </p>
  
  <p>The JSFiddle has an input for the <code>original_value</code> and an input for the <code>multiplier</code>.  </p>
  
  <p>It outputs the result to four decimal places and adds trailing zeros where required (this is the required format for the result).  </p>
  
  <p>It is an attempt to check that the Javascript code I am writing will produce the same result as the Google Sheet formula.  </p>
  
  <p>[ The JSFiddle has been updated to also log <code>decimal.js</code> results to the console for comparison ]</p>
  
  <p><strong>Edit</strong></p>
  
  <p>There was a suggestion to use <a href="https://github.com/MikeMcl/decimal.js" rel="nofollow noreferrer">decimal.js</a> but I'm not sure how it would be applied - something like the following?</p>
  
  <pre><code>var original_value = new Decimal(1.1000);
  
  // some different multipliers for testing
  var multiplier_a = new Decimal(1.073); 
  var multiplier_b = new Decimal(1.1);
  
  // some different results for testing
  var derivative_value_a = original_value.times(multiplier_a).toString();
  var derivative_value_b = original_value.times(multiplier_b).toString();
  
  console.log(derivative_value_a);  //  1.1803
  console.log(derivative_value_b);  //  1.21
  </code></pre>
  
  <p>Is that any more accurate than plain Javascript <code>original_value * multiplier</code>?  More importantly for this question, will it always simulate the same result that a Google Sheet formula produces?  </p>