I'm not saying you should read all this, but this issue is a well known fact about floating point math in programing languages, and it's present in lots of languages. http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html Gedece On Fri, Mar 30, 2012 at 10:04, Steven Owens <lists / ruby-forum.com> wrote: > Hello guys, > > I'm just starting out with the Ruby language, and appear to either be > doinf something wrong, or have run into a rather basic math bug. ¨Âèå> running "irb", simple math additions seem to sometimes have weird > results. ¨Âïò éîóôáîãå> > 1.9.3-p125 :022 > 120.02+82 > > 202.01999999999998 > > but then > > 1.9.3-p125 :023 > 120.03+82 > > 202.03 > > This anomoly seems to be repeatable on a friends box as well. ¨Âæéòóô¬ > I was onyl able to trigger this with a 3 digit number starting with a 1, > with .08 after, plus a 2 digit number. ¨Âï÷åöåòãèåãëåæåïôèå> combinations have also had this kind of issue. > > 1.9.3-p125 :030 > 120.009+82 > > 202.00900000000001 > > Here is a few more examples > > 1.9.3-p125 :021 > 120.01+82 > > 202.01 > 1.9.3-p125 :022 > 120.02+82 > > 202.01999999999998 > 1.9.3-p125 :023 > 120.03+82 > > 202.03 > 1.9.3-p125 :024 > 120.04+82 > > 202.04000000000002 > 1.9.3-p125 :025 > 120.05+82 > > 202.05 > 1.9.3-p125 :026 > 120.06+82 > > 202.06 > 1.9.3-p125 :027 > 120.07+82 > > 202.07 > 1.9.3-p125 :028 > 120.08+82 > > 202.07999999999998 > 1.9.3-p125 :029 > 120.09+82 > > 202.09 > > Now since I'm quite new to this, I realize that this could of course be > something I'm doing wrong, but obviously, since I'm tyring to learn, I'd > like to know why I'm getting these results. ¨Âèáîëéî áäöáîãçõùó> > -- > Posted via http://www.ruby-forum.com/. >