title: Algorithm to efficiently apply a decimal shift to all numbers
body: <p>I'm in the process of setting up a chemical model that takes inputs as mols, but discretely simulates the molecules (i.e., each molecule is one entity). As a result, I need to be able to calculate out the proportions as  whole numbers. For example if I have 0.01 mols of <em>A</em> and 0.002 mols of <em>B</em> I would scale that out to 10 units of <em>A</em> and 2 units of <em>B</em>. However, this code is pretty inelegant and assumes that all molar counts will be less than 1.0, i.e.,</p>
  
  <pre class="lang-java prettyprint-override"><code>// Find the exponent to offset the value
  NumberFormat format = new DecimalFormat("0.#E0");       
  String value = format.format(smallest);
  int exponent = Integer.parseInt(value.substring(value.indexOf("E") + 1));
  
  // Scale to whole numbers
  exponent = Math.abs(exponent) + 1;
  for (int ndx = 0; ndx &lt; input.size(); ndx++) {
      input.get(ndx).count = (long)(input.get(ndx).mols * Math.pow(10, exponent)); 
  }
  </code></pre>
  
  <p>Is there an efficient algorithm to perform decimal shift on arbitrary inputs (ex., 1.1 mols of <em>A</em>, 0.11 mols of <em>B</em>, 0.001 mols of <em>C</em> befomes 1100 units of <em>A</em>, 110 units of <em>B</em>, and 1 unit of <em>C</em>)?</p>