Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Mike Amling Newsgroups: comp.lang.java.programmer Subject: Re: 64-bit hashing function Date: Mon, 05 May 2014 11:03:33 -0500 Lines: 31 Message-ID: References: <5mvel9lrq0upfvobfbssrait15iicoi6ak@4ax.com> <5fgkl9hsqkh0i44cgf1fooa96gutfjivcm@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Op7L8+HROVtyPyFov2EZPA8ovtvvQGNP7RRK4GPFkddqJgMYu+ Cancel-Lock: sha1:fn0ScuCezXti1iNFD/3CJmsO4vg= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: <5fgkl9hsqkh0i44cgf1fooa96gutfjivcm@4ax.com> Xref: csiph.com comp.lang.java.programmer:28374 On 4/25/14 6:08 AM, Roedy Green wrote: > On Wed, 23 Apr 2014 09:57:11 +0100, rossum > wrote, quoted or indirectly quoted someone who said : > >> I usually suggest the FNV hash for this sort of situation: >> http://isthe.com/chongo/tech/comp/fnv/ > > > I have posted Java code for the 32 and 64-bit version at > http://mindprod.com/jgloss/digest.html > > The only tricky part is defining a long unsigned magic number. > > They should show up within the hour. Have you tested that code? You have hash^=b; Isn't that going to sign-extend the byte before doing the XOR? IIRC, FNV treats the byte as unsigned. To be compatible with other FNV1a implementations, wouldn't you need hash^=(b & 0xFF); or equivalent? Of course, if interoperability is irrelevant, you're free to do as you please. Mike Amling -- VGhlIFJlaWduIG9mIEVycm9y