Open dushaoshuai opened 1 year ago
func RoundPrecision(x float64, precision int) float64 { ratio := math.Pow10(precision) return math.Round(x*ratio) / ratio }
func RoundUpPrecision(x float64, precision int) float64 { ratio := math.Pow10(precision) return math.Ceil(x*ratio) / ratio }
func RoundDownPrecision(x float64, precision int) float64 { ratio := math.Pow10(precision) return math.Floor(x*ratio) / ratio }
round to nearest
round up
round down