summaryrefslogtreecommitdiff
path: root/utils.go
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2018-09-15 10:58:27 +0200
committerNikolaus Gotsche <n@softwarefools.com>2018-09-15 10:58:27 +0200
commit8f1891352a2f3296d5edf4ba7688d16ea2053266 (patch)
treeee2f7f5d7f1bfb449a86184de8d51a1da7b10b8d /utils.go
parent7848ecdbcabc728fe11df1943096682f1f89d89b (diff)
Tried to force it for go 1.70.2.3
Diffstat (limited to 'utils.go')
-rw-r--r--utils.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/utils.go b/utils.go
index 1400d63..c559b2e 100644
--- a/utils.go
+++ b/utils.go
@@ -133,8 +133,17 @@ func string2StringArray(in string,delim string)(out []string) {
return
}
+func RetardRound(x float64) float64 {
+ t := math.Trunc(x)
+ if math.Abs(x-t) >= 0.5 {
+ return t + math.Copysign(1, x)
+ }
+ return t
+}
+
func Round(x, unit float64) (float64) {
- return math.Round(x/unit) * unit
+// return math.Round(x/unit) * unit
+ return RetardRound(x/unit) * unit
}
func cleanString(in string) (out string) {