From: Chris Hulan Date: 2009-07-24T23:05:08+09:00 Subject: Re: Arithmetic operation bug On Jul 24, 9:11 am, Manoj Chourasia wrote: > v1="128.015" > puts((v1.to_f*1000).to_i).to_s // giving 128014 instead of 128015 > > Why the the result is rounding up to 128014 but the correct result > should be 128015. > -- > Posted viahttp://www.ruby-forum.com/. Floats are tricky: (120..130).each{|x| puts x,((x+0.015)*1000).to_i} Have a look at "What Every Computer Scientist Should Know About Floating-Point Arithmetic" (http://docs.sun.com/source/806-3568/ ncg_goldberg.html)