On Mon, Aug 4, 2008 at 7:38 AM, The Podman <poddster / gmail.com> wrote:

> * Float == Float does not perform any delta difference checking. In a
> way, this is expected. In another way, it's not.

If you don't like the == method of Float just crack it open and change it:

a = 12.60000000000001
b = 12.59999999999999

puts a
puts b

puts a == b   # => false

class Float
  def ==(other)
    fuzz = 1.0E-10
    max = [self.abs, other.abs].max
    ( self - other ).abs / max < fuzz
  end
end

puts a == b # => true

I would only recommend doing this for your tests though, other code
might want the original == method intact.


-- 

-Daniel