Last active
August 29, 2015 14:14
-
-
Save maxxfrazer/08ea24eaedd438519204 to your computer and use it in GitHub Desktop.
minimal round function 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
package main | |
import ( | |
"log" | |
"math" | |
) | |
func Round(val float64) float64 { | |
return math.Floor(val + 0.5) | |
} | |
func main() { | |
log.Println(Round(22.1)) | |
log.Println(Round(163.49)) | |
log.Println(Round(163999.9)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
playground for this: https://play.golang.org/p/J7-6GKt0_B