title: What is the fastest way to round to three decimal places?
body: <p>The SO community was right, profiling your code before you ask performance questions seems to make more sense then my approach of randomly guessing :-)  I profiled my code(very intensive math) and didn't realize over 70% of my code is apparently in a part I didn't think was a source of slowdown, rounding of decimals.</p>
  
  <pre><code>static double roundTwoDecimals(double d) {
      DecimalFormat twoDForm = new DecimalFormat("#.###");
      return Double.valueOf(twoDForm.format(d));
  }
  </code></pre>
  
  <p>My problem is I get decimal numbers that are normally .01,.02,etc..but sometimes I get something like .070000000001 (I really only care about the 0.07 but floating point precision causes my other formulas that result to fail), I simply want the first 3 decimals to avoid this problem.</p>
  
  <p>So is there a better/faster way to do this?</p>