From: ara.t.howard@... Date: 2006-11-09T02:47:16+09:00 Subject: Re: Simple Math Problem On Thu, 9 Nov 2006, Thom Loring wrote: > Can anyone shed some light on a simple math problem I have encountered? > I am doing a very simple calculation, and the comparison of that result > compared to the number itself is returning false in some cases...for > instance: > > $irb >>> v1 = 80.04 > => 80.04 > >>> v2 = 0.12 * 667 > => 80.04 > >>> v1 == v2 > => false > >>> v1 > v2 > => true > >>> v1 < v2 > => false > >>> v1.inspect > => "80.04" > >>> v2.inspect > => "80.04" > > Any insight? > > Thanks, > Thom http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems -a -- my religion is very simple. my religion is kindness. -- the dalai lama