Created
March 3, 2016 19:02
-
-
Save skarllot/301798f3f21a3b3547fc to your computer and use it in GitHub Desktop.
Round to integer for golang
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(a float64) float64 { | |
if a < 0 { | |
return math.Ceil(a - 0.5) | |
} | |
return math.Floor(a + 0.5) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment