github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/vector/compare/help_test.go (about) 1 package compare 2 3 func equalFloats(xs, ys []float32) bool { 4 const epsilon = 1e-3 5 6 if len(xs) != len(ys) { 7 return false 8 } 9 10 for i, x := range xs { 11 delta := ys[i] - x 12 if delta < 0 { 13 delta = -delta 14 } 15 if delta > epsilon { 16 return false 17 } 18 } 19 20 return true 21 }