Created
July 2, 2020 19:57
-
-
Save jbsmith7741/d41cf55d323ae77aab3fad007f2d6060 to your computer and use it in GitHub Desktop.
truncate float
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 trunc(val float64, digit int) float64 { | |
pow := math.Pow(10.0, float64(digit)) | |
return math.Floor(pow*val) / pow | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment