title: How to count the number of zeros in a decimal?
body: <p>What is the most efficient way to calculate the number of 0s in a decimal before the first non 0 number?</p>
  
  <p>Desired outcome:</p>
  
  <pre class="lang-none prettyprint-override"><code>0.0000456 ---&gt; 4
  0.00406 ---&gt; 2
  0.000456 ---&gt; 3
  </code></pre>
  
  <p>So far I have tried mathematically this (which is slow):</p>
  
  <pre><code>from math import floor, log
  
  def num_zeros(decimal):
      return 10 - floor(log(decimal *10e10,10))
  </code></pre>
  
  <p>and this (which is not right as 0 after a first number will be counted):</p>
  
  <pre><code>def count_0(number):
      n = format(number, 'f').count('0')
      return n - 1
  </code></pre>