From: Glenn Parker Date: 2005-03-31T23:52:50+09:00 Subject: Re: Integer/Float oddity horati0@linuxmail.org wrote: > not really an oddity, more a lack of understanding on my part regarding > ruby's internal type conversion... > > (100*(1.15-1)) > => 15.0 > > (100*(1.15-1)).to_int > => 14 > > (100*(1.15-1)).to_int.round > => 15 FWIW, I get 14. Perhaps you meant (100*(1.15-1)).round.to_int ? Float#to_int simply truncates, while Float#round goes to the nearest integer. Try this: "%.20f" % (100*(1.15-1)) -- Glenn Parker | glenn.parker-AT-comcast.net |