From ceff486ce21eca34a8ce8a6ecb7cc3150b206851 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 21 May 2017 18:32:45 +0200 Subject: Rename --- round.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'round.go') diff --git a/round.go b/round.go index d1c625e..345f7b0 100644 --- a/round.go +++ b/round.go @@ -7,8 +7,8 @@ import "math" // = -\sgn(y) \left\lceil -\left| y \right| - 0.5 \right\rceil // Round a float value to n decimal places -func Round(v float64, places int) float64 { - scale := math.Pow(10, float64(places)) - abs := math.Abs(v*scale) + 0.5 - return math.Copysign(math.Floor(abs)/scale, v) +func Round(v float64, n int) float64 { + pow := math.Pow(10, float64(n)) + abs := math.Abs(v*pow) + 0.5 + return math.Copysign(math.Floor(abs)/pow, v) } -- cgit v1.2.3