Question : golang round float to number of digits
Answered by : smjure
// Rounds float64 number to nbDigits
func Round(num float64, nbDigits float64) float64 { pow := math.Pow(10., nbDigits) rounded := float64(int(num*pow)) / pow return rounded
}
Source : | Last Update : Mon, 29 Nov 21