From: Robert Parker Date: 2008-11-08T16:55:36+09:00 Subject: Re: what's easiest way to compare a Float & BigDecimal (i.e. like a equals mechanism) On Sat, Nov 8, 2008 at 2:44 PM, Greg Hauptmann wrote: > that works - but my 6.5 number doesn't work - does the following also > not work for you? > >>> a = BigDecimal.new('6.5') > => # >>> b = 6.5 > => 6.5 >>> a == b > => false >>> a.class > => BigDecimal >>> b.class > => Float >>> > You can rely on comparing floating point numbers for less than or greater than only. You can not reliably compare floating point numbers for equality period. -- In a world without walls who needs Windows (or Gates)? Try Linux instead!