due to the change to 64 bit ints in tip, I noticed that 64 bit integer
division is almost three times slower than 32 bit integer division, on an
amd64 system[1].
On Sat, Jan 19, 2013 at 10:13 PM, Dominik Honnef <domi...@fork-bomb.org> wrote:
Cannot reproduce here (Xeon on dont-know-how-much GHz)
jnml@fsc-r630:~/src/tmp/20130119$ cat a_test.go
package main
import (
"testing"
)
func BenchmarkBase(b *testing.B) {
var x int32
for i := 1; i < b.N; i++ {
}
_ = x
}
func BenchmarkInt(b *testing.B) {
var x int
for i := 1; i < b.N; i++ {
x /= 42
}
_ = x
}
A=2^62
B=13
A/B = 4611686018427387904/13
A/B = quotient 354745078340568300 with remainder 4
A/B = (82595524*2^32 + 3964585196) with remainder 4
Consider the quotient:
H = Upper 32 bits of 354745078340568300 = 82595524
L = Lower 32 bits of 354745078340568300 = 3964585196
Apparently you want L.
uint32(uint64(354745078340568300)) = 3964585196
The overflow condition is that the quotient is not representable in 32 bits. Reference:
http://stackoverflow.com/questions/22596059/problems-dividing-64-bits-in-x86-assembly