FAQinghere
7/28/2017 - 3:47 AM

rounding

rounding

func nearestMultiple(val, m int64) int64 {
	return m * round(float64(val)/float64(m))
}

func round(f float64) int64 {
	return int64(f + math.Copysign(0.5, f))
}