Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (14 sloc) 334 Bytes
package utils
import (
"math"
)
func Round(val float64, prec int) float64 {
var rounder float64
intermed := val * math.Pow(10, float64(prec))
if val >= 0.5 {
rounder = math.Ceil(intermed)
} else {
rounder = math.Floor(intermed)
}
return rounder / math.Pow(10, float64(prec))
}
Jump to Line
Something went wrong with that request. Please try again.