From: Mark Brassard Date: 2009-09-11T03:48:20+09:00 Subject: Re: hash value inconsistencies Tim Pease wrote: > ruby -e "puts 'test'.hash" > > Should this output the same integer value on all platforms where Ruby > can run? > > * Windows > ruby --version #=> ruby 1.8.6 (2007-03-13 patchlevel 0) [i386- > mswin32] > ruby -e "puts 'test'.hash" #=> -914358341 > > * Mac 10.5 > ruby --version #=> ruby 1.8.6 (2007-03-13 patchlevel 0) [i686- > darwin8.10.3] > ruby -e "puts 'test'.hash" #=> -914358341 > > * Linux 2.6 Kernel > ruby --version #=> ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64- > linux] > ruby -e "puts 'test'.hash" #=> 1233125307 > > ruby --version #=> ruby 1.8.5 (2006-12-04 patchlevel 2) [x86_64- > linux] > ruby -e "puts 'test'.hash" #=> 1233125307 > > > 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. > > Thoughts? > > TwP The problem is that some of your test machines are 64-bit and some are 32-bit. I Ran the same tests on some Macs running Snow Leopard(64-bit) and Leopard(32-bit) and Linux (64-bit) and Linux (32-bit) and all results were consistent over OSes with the same bits. -- Posted via http://www.ruby-forum.com/.