Created
July 22, 2017 07:15
-
-
Save cptangry/0431c1831bf2a8afbe8f7a9dba6d22d4 to your computer and use it in GitHub Desktop.
Büyük hizmet! GO Programlama Dili için Round Fonksiyonu
This file contains hidden or 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 Round(val float64, roundOn float64, places int ) (newVal float64) { | |
var round float64 | |
pow := math.Pow(10, float64(places)) | |
digit := pow * val | |
_, div := math.Modf(digit) | |
if div >= roundOn { | |
round = math.Ceil(digit) | |
} else { | |
round = math.Floor(digit) | |
} | |
newVal = round / pow | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment