title: C# Check if a decimal has more than 3 decimal places?
body: <p>I have a situation that I cannot change: one database table (table A) accepts 6 decimal places, while a related column in a different table (table B) only has 3 decimal places.  </p>
  
  <p>I need to copy from A to B, but if A has more than 3 decimal places the extra data will be lost.  I cant change the table definition but I can add a workaround. So I'm trying to find out how to check if a decimal has more than 3 decimal places or not?  </p>
  
  <p>eg</p>
  
  <pre><code>Table A
  Id, Qty,  Unit(=6dp)
  1,  1,     0.00025
  2,  4000,  0.00025
  
  Table B
  Id, TotalQty(=3dp)
  </code></pre>
  
  <p>I want to be able to find out if Qty * Unit from Table A has more than 3 decimals (row 1 would fail, row 2 would pass):</p>
  
  <pre><code>if (CountDecimalPlaces(tableA.Qty * tableA.Unit) &gt; 3)
  {
      return false;
  }
  tableB.TotalQty = tableA.Qty * tableA.Unit;
  </code></pre>
  
  <p>How would I implement the <code>CountDecimalPlaces(decimal value) {}</code> function?</p>