Last active
November 18, 2020 02:26
-
-
Save pignuante/f46eb9d6bcfc3d02f9f453483273ee33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func round(num float64) int { | |
return int(num + math.Copysign(0.5, num)) | |
} | |
func floatRound(num float64, precision int) float64 { | |
output := math.Pow(10, float64(precision)) | |
return float64(round(num * output)) / output | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment