Create a gist now

Instantly share code, notes, and snippets.

@yukirin /round.go
Last active Feb 6, 2016

What would you like to do?
Goであると思ってたけど、なかった関数、定数 round
import "math"
func round(f float64, place int) float64 {
shift := math.Pow10(place)
return math.Floor(f*shift+.5) / shift
}
func round1(f float64) float64 {
return math.Floor(f + .5)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment