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.  When
running "irb", simple math additions seem to sometimes have weird
results.  for instance.

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.  At first,
I was onyl able to trigger this with a 3 digit number starting with a 1,
with .08 after, plus a 2 digit number.  However, checked a few other
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.  Thanks in advance guys.

-- 
Posted via http://www.ruby-forum.com/.