Last active
February 6, 2016 14:58
-
-
Save yukirin/9a81bf567eda4c5bd159 to your computer and use it in GitHub Desktop.
Goであると思ってたけど、なかった関数、定数 round
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
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