From: "Thomas B." Date: 2009-07-23T02:02:59+09:00 Subject: Re: Incorrect -0.0.hash - Ruby bug. James Coglan wrote: > > Is there a reason for this? Perhaps the inexact nature of Floats means > you > ought not to use them as hash keys? In my program it's very convenient to use float vectors as keys because I create a graph where points (vertices) are calculated numerically as cross points of lines and so on (that's why I get -0.0 from time to time). I round the floats to 8 decimal digits, and added a quick fix for the hash: alias :hash_orig :hash def hash eql?(0.0) ? 0.0.hash_orig : hash_orig end and it works like it should, so I think it was a good idea to use them as keys :) -- Posted via http://www.ruby-forum.com/.