Skip to content

Commit 0d9e788

Browse files
author
Jaybeecave
committed
Round
1 parent 2bc5c4e commit 0d9e788

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

helpers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,10 @@ func PadIntLeft(num int, len int, pad string) string {
7070
str := strconv.Itoa(num)
7171
return PadLeft(str, len, pad)
7272
}
73+
74+
func Round(val float64) int {
75+
if val < 0 {
76+
return int(val - 0.5)
77+
}
78+
return int(val + 0.5)
79+
}

0 commit comments

Comments
 (0)