From: Mike Gold Date: 2009-02-13T14:56:53+09:00 Subject: Re: Bug in converting float to int? Jeff Vogt wrote: > I just tried this on 1.8.6. Is this a bug or am I missing something? > >>> a=10.12 > => 10.12 >>> (a*100).to_i > => 1011 > > And if this is in fact intended behavior, how can I actually get the > results I want? (Converting dollars and cents into cents) A FAQ. irb(main):001:0> sprintf("%.16f", 100*10.12) => "1011.9999999999998863" http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems -- Posted via http://www.ruby-forum.com/.