Eliminated the stupid offset bug in interleaving. Hail to to the unit test.

This commit is contained in:
Sascha L. Teichmann 2014-09-07 10:46:51 +02:00
parent 45ec5ccd3e
commit 8d4f73429f
2 changed files with 6 additions and 6 deletions

View File

@ -14,8 +14,8 @@ const (
numBitsPerComponent = 12
modulo = 1 << numBitsPerComponent
maxPositive = modulo / 2
minValue = -1 << numBitsPerComponent
maxValue = 1<<numBitsPerComponent - 1
minValue = -1 << (numBitsPerComponent - 1)
maxValue = 1<<(numBitsPerComponent-1) - 1
)
type (
@ -272,13 +272,13 @@ func BigMin(minz, maxz, zcode int64) int64 {
pos := msb
for m := int64(1) << msb; m != 0; m >>= 1 {
var v uint8
if zcode&m != 0 {
if zcode&m == m {
v = _100_
}
if minz&m != 0 {
if minz&m == m {
v |= _010_
}
if maxz&m != 0 {
if maxz&m == m {
v |= _001_
}
switch v {

View File

@ -181,7 +181,7 @@ func outsiders(zmin, zmax int64, fn func(int64)) {
}
func TestBigMin(t *testing.T) {
const tries = 10
const tries = 20
for i := 0; i < tries; i++ {
x1 := rand.Intn(4000) - 2000
y1 := rand.Intn(4000) - 2000