title: Odd behavior of int(x) in python
body: <p>When running this program,</p>
  
  <pre><code>cost = 12
  money = 12.51
  change = money - cost
  
  dollars = int(change)
  change -= dollars
  
  quarters = int(change / 0.25)
  change -= quarters * 0.25
  
  dimes = int(change / 0.1)
  change -= dimes * 0.1
  
  nickels = int(change / 0.05)
  change -= nickels * 0.05
  
  pennies = int(change / 0.01)
  
  print("""Your change is:
      %i dollars
      %i quarters
      %i dimes
      %i nickels
      %i pennies
  """ % (dollars, quarters, dimes, nickels, pennies))
  </code></pre>
  
  <p>The output is</p>
  
  <pre><code>Your change is:
      0 dollars
      2 quarters
      0 dimes
      0 nickels
      0 pennies
  </code></pre>
  
  <p>Why is pennies 0? I've tried printing pennies separately, same thing happens. I know for certain as well that <code>change / 0.01</code> is equal to <code>1.0</code>. For some reason, it seems that <code>int(1.0)</code> is equal to <code>0</code>. Obviously, it's not. Maybe <code>1.0</code> is a floating point number that isn't actually 1 and gets floored to <code>0</code>?</p>
  
  <p>Sidenote: Removing int function on pennies and replacing with <code>%.0f pennies</code> works.</p>
  
  <p>I guess this is exactly what people talk about when they say not to use floating point numbers when working with money. :)</p>