From: Mark Thomas Date: 2008-11-11T01:47:51+09:00 Subject: Re: what's easiest way to compare a Float & BigDecimal (i.e. like a equals mechanism) On Nov 8, 1:26 am, Greg Hauptmann wrote: > Hi, > > what's easiest way to compare a Float & BigDecimal (i.e. like a equals > mechanism)?  It seems that "==" does NOT work as they are different > types.  Is there a way to do a comparison without having to convert > types? > > ?> a > => #>> x > => 6.5 > >> a == x > > => false      #<<== DIDN'T WORK I thought I saw a similar discussion not too long ago... aha: http://groups.google.com/group/comp.lang.ruby/msg/bc1e54150d1d45d5 With the approx_equal? method in that thread, this works: a = BigDecimal.new('6.5') f = 6.5 f == a #=> false f.approx_equal?(a, 0.00000000001) #=> true -- Mark.