From: Tim Pease Date: 2008-02-06T08:15:21+09:00 Subject: Re: hash value inconsistencies On Feb 5, 2008, at 4:04 PM, Clifford Heath wrote: > Tim Pease wrote: >> Should this output the same integer value on all platforms where >> Ruby can run? > > Perhaps, but if you read the below, you'll see why you should never > rely > on it. > >> It appears not! So, any suggestions on generating an ID number for >> an object that is unique yet consistent across different >> platforms? I'd like to have some method that I could call on an >> object that would return a reproducible value that would uniquely >> identify that object. > > That's not possible. There is more entropy in an arbitrary object than > can be represented in a FixNum. Basic coding theory stuff. If it was > possible, then you could code all the data in all the databases in the > world into a single Fixnum :-). Darn information theory! I just need a fixnum. The number of objects we are creating is pretty tiny -- maybe 100. I was quite surprised that the Ruby "hash" method is not consistent across platforms. The solution is to roll my own hash function that produces consistent results. Just wondering about the more general questions regarding the built in hash function. Blessings, TwP