github.com/tobgu/qframe@v0.4.0/internal/math/float/float.go (about) 1 package float 2 3 import ( 4 "math" 5 ) 6 7 func Round(n float64) int { 8 return int(n + math.Copysign(0.5, n)) 9 } 10 11 func Fixed(num float64, precision int) float64 { 12 i := math.Pow(10, float64(precision)) 13 return float64(Round(num*i)) / i 14 }