Skip to content

Instantly share code, notes, and snippets.

@maxxfrazer
Last active August 29, 2015 14:14
Show Gist options
  • Save maxxfrazer/08ea24eaedd438519204 to your computer and use it in GitHub Desktop.
Save maxxfrazer/08ea24eaedd438519204 to your computer and use it in GitHub Desktop.
minimal round function for golang
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))
}
@maxxfrazer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment