I was playing with an MD5 implementation and coded up the following for the binary part of the sines of integers, using the pseudocode found on wikipedia. I've found discrepancies between my output and the precomputed table widely available.
I'm trying to figure out if my code is incorrect or the pseudocode on Wikipedia is incorrect. Replacing math.Floor with math.Ceil in the code below fixes the discrepancies between the precomputed table and my output.
package main
import "fmt"
import "math"
func main() {
var i float64
for i < 64 {
x := uint(math.Floor(float64(math.MaxUint32) * math.Abs(math.Sin(i+1))))
fmt.Printf("%d : %x\n", uint(i+1), x)
i = i + 1
}
}
1 : d76aa477
2 : e8c7b755
3 : 242070db
4 : c1bdceee
Lines 1 and 2 different from the precomputed table, while line 3 is in agreement.