title: Find the number of digits after the decimal point
body: <p>I'm trying to write a Python 2.5.4 code to write a function that takes a floating-point number x as input and returns the number of digits after the decimal point in x.</p>
  <p>Here's my code:</p>
  <pre><code>def number_of_digits_post_decimal(x):
      count = 0
      residue = x -int(x)
      if residue != 0:
          multiplier = 1
          while int(multiplier * residue) != (multiplier * residue):
              count += 1
              multiplier = 10 * multiplier
              print count
              print multiplier
              print multiplier * residue
              print int(multiplier * residue)
              return count
  
  print number_of_digits_post_decimal(3.14159)
  </code></pre>
  <p>The print statements within the while loop are only for debugging purposes.</p>
  <p>Now when I run this code, I get the following as output.</p>
  <blockquote>
  <p>1</p>
  <p>10</p>
  <p>1.4159</p>
  <p>1</p>
  <p>2</p>
  <p>100</p>
  <p>14.159</p>
  <p>14</p>
  <p>3</p>
  <p>1000</p>
  <p>141.59</p>
  <p>141</p>
  <p>4</p>
  <p>10000</p>
  <p>1415.9</p>
  <p>1415</p>
  <p>5</p>
  <p>100000</p>
  <p>14159.0</p>
  <p>14158</p>
  <p>6</p>
  <p>1000000</p>
  <p>141590.0</p>
  <p>141589</p>
  <p>7</p>
  <p>10000000</p>
  <p>1415900.0</p>
  <p>1415899</p>
  <p>8</p>
  <p>100000000</p>
  <p>14159000.0</p>
  <p>14158999</p>
  <p>9</p>
  <p>1000000000</p>
  <p>....</p>
  </blockquote>
  <p>The final value of count as returned by this function is 17.</p>
  <p>How to modify this code in order to achieve our desired result?</p>