]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix float64 hash on 32-bit machine
authorRuss Cox <rsc@golang.org>
Mon, 6 Feb 2012 16:24:34 +0000 (11:24 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 6 Feb 2012 16:24:34 +0000 (11:24 -0500)
Multiplying by the low 32 bits was a bad idea
no matter what, but it was a particularly unfortunate
choice because those bits are 0 for small integer values.

Fixes #2883.

R=ken2
CC=golang-dev
https://golang.org/cl/5634047

src/pkg/runtime/alg.c

index eec523aad4dd589449d5175ae63d7a6938df5058..e3c42916e97e48e799eb6613e969b2fbd51ed931 100644 (file)
@@ -271,7 +271,7 @@ runtimeĀ·f64hash(uintptr *h, uintptr s, void *a)
        else {
                u = *(uint64*)a;
                if(sizeof(uintptr) == 4)
-                       hash = ((uint32)(u>>32) ^ 2860486313) * (uint32)u;
+                       hash = ((uint32)(u>>32) * 3267000013UL) ^ (uint32)u;
                else
                        hash = u;
        }