From: James Edward Gray II Date: 2007-02-09T03:54:33+09:00 Subject: Re: Testing Float equality (was: Negative Float conversion to Fixnum) On Feb 8, 2007, at 12:50 PM, Drew Raines wrote: > Wolfgang N�dasi-Donner wrote: > >> Drew Raines schrieb: >>> Can I workaround this? >> >> If you always expect a result for which "x * 100" is a number without >> a fractional part, you can use "(-39.30 * 100).round" instead. > > Hal Fulton[1] gave me a good idea: > > class Float > FUDGE = 1e-3 > def ==(x) > (self-x).abs < FUDGE > end > end > > This is better for my tests anyway. assert_equal now works on its > own. Test::Unit already includes an assertion just for this. It's called assert_in_delta(). James Edward Gray II