utils/numbers.go

10 lines
186 B
Go
Raw Normal View History

2023-10-02 23:42:16 +02:00
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
}