title: Convert BigDecimal to cents
body: <p>I want to convert a BigDecimal in Ruby to cents, here is what I did:</p>
  
  <pre><code>amount = BigDecimal('19.95')
  #=&gt; #&lt;BigDecimal:7f80bc726b38,'0.1995E2',18(18)&gt; 
  amount_in_cents = amount*100
  #=&gt; #&lt;BigDecimal:7f80bc794cc8,'0.1995E4',9(45)&gt; 
  amount_in_cents.to_f
  #=&gt; 1995.0
  amount_in_cents.ceil
  #=&gt; 1995
  </code></pre>
  
  <p>So <code>ceil</code> gives me the right amount in cents, the amount I need to communicate to the payment provider. At the moment I'm not 100% sure if what I did here is correct. Maybe somebody knows a better way?</p>