utils/numbers.go
2023-10-02 23:42:16 +02:00

10 lines
186 B
Go

package utils
import "math"
// RoundFloat rounds f to precision p
func RoundFloat(f float64, p uint) float64 {
ratio := math.Pow(10, float64(p))
return math.Round(f*ratio) / ratio
}