From: Michael Morin Date: 2008-11-10T16:28:05+09:00 Subject: Re: what's easiest way to compare a Float & BigDecimal (i.e. like a equals mechanism) Greg Hauptmann wrote: > oh so convert the BigDecimal to a float by multiplying by 1.0 you mean first? > > On Sun, Nov 9, 2008 at 6:12 AM, pen wrote: >> On Nov 8, 8: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? >> Actually, there is none. Why don't you just let Ruby do the job and >> multiply the bigdecimal with 1.0 when comparing? Also, as previously >> noted, == operator with floats is not ... reliable. >> >> br, >> >> pen >> >> > BigDecimal objects should have a to_f method. Using that would probably be more clear than multiplying by 1.0 (a seamingly meaningless thing to do).