title: Get number of total decimal places in decimal (including non-significant ones)
body: <p>If you run this code:</p>
  
  <pre><code>decimal d1 = 0m; 
  decimal d2 = 0.0m;
  decimal d3 = 0.0000m;
  
  string str1 = d1.ToString(System.Globalization.CultureInfo.InvariantCulture);
  string str2 = d2.ToString(System.Globalization.CultureInfo.InvariantCulture);
  string str3 = d3.ToString(System.Globalization.CultureInfo.InvariantCulture);
  </code></pre>
  
  <p>You get : </p>
  
  <pre><code>str1: "0",
  str2: "0.0",
  str3: "0.0000"
  </code></pre>
  
  <p>Is there some way in code to get the number of decimal places (as would be output by decimal.ToString above) in the decimal variables ?</p>
  
  <p>i.e. want to get:</p>
  
  <pre><code>d1: 0
  d2: 1
  d3: 4
  </code></pre>
  
  <p>(In case anyone is wondering why this is required, it is for some workaround code for a problem involving SSRS and Excel: <a href="http://social.technet.microsoft.com/Forums/sqlserver/en-US/5c4fc104-5d69-409d-9a6e-a6354922729a/exporting-ssrs-report-to-excel-2007-excel-found-unreadable-content-in-file-xlsx" rel="nofollow">http://social.technet.microsoft.com/Forums/sqlserver/en-US/5c4fc104-5d69-409d-9a6e-a6354922729a/exporting-ssrs-report-to-excel-2007-excel-found-unreadable-content-in-file-xlsx</a>)</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Title has been changed. Sorry for the confusion, guys. In the underlying problem I'm trying to solve, the decimals are always 0 - hence the confusion. </p>