From: Eleanor McHugh Date: 2008-07-02T22:12:40+09:00 Subject: Re: Arithmetic oddity On 2 Jul 2008, at 13:48, Minh Tran wrote: > It still look odd as the value in s[2] is 2.0 which doesn't seems to > have any rounding problem. > > In any case is there any workaround to fix get the condition as true ? Floating point representations are in many cases (such as irrational numbers like square root of 2) only approximations to a given value, you therefore have to test that the value is accurate to a given precision (number of significant digits). For example, given: x = (1.0 + 1.0) ** 0.5 you could write your test as: (x ** 2.0).between?(1.9999, 2.0001) Ellie Eleanor McHugh Games With Brains http://slides.games-with-brains.net ---- raise ArgumentError unless @reality.responds_to? :reason