title: How to out-of-range error check this double to string converter with specific decimal precision?
body: <p>I am using this routine to convert a double to a string with keeping only two decimal numbers:</p>
  
  <pre><code>private string DoubleToString(double num)
  {
     string buffer = num.ToString();
     return buffer.Substring(0, buffer.IndexOf(".") + 2);
  }
  </code></pre>
  
  <p>However, sometimes the actual value of the parameter <code>num</code> is only 1 decimal. How can I error check that?</p>