github.com/pavlo67/common@v0.5.3/common/mathlib/float.go (about) 1 package mathlib 2 3 import "math" 4 5 func Round(val float64, precision uint) float64 { 6 ratio := math.Pow(10, float64(precision)) 7 return math.Round(val*ratio) / ratio 8 }