summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-05-21 18:32:45 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-05-21 18:32:45 +0200
commitceff486ce21eca34a8ce8a6ecb7cc3150b206851 (patch)
tree60c089b44ae6ed0e49ed44bbc764e85cf9d47f2c
parentdb72567ed07dd958157ba0aee5c157e688deadd6 (diff)
Rename
-rw-r--r--round.go8
1 files changed, 4 insertions, 4 deletions
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)
}