diff options
Diffstat (limited to 'utils.go')
| -rw-r--r-- | utils.go | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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) { |
