From 05f8b6ad6bf049ff9ca8b3b8464767f3f3c4338a Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 29 Apr 2018 14:42:49 +0100 Subject: [PATCH] Fix bug in math.spread() SQL function --- util/fncs/math_test.go | 2 +- util/math/spread.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/fncs/math_test.go b/util/fncs/math_test.go index b3e57c04..dfdef0f4 100644 --- a/util/fncs/math_test.go +++ b/util/fncs/math_test.go @@ -227,7 +227,7 @@ func TestMath(t *testing.T) { res, _ = Run(context.Background(), "math.spread", 10) So(res, ShouldEqual, 0) res, _ = Run(context.Background(), "math.spread", test) - So(res, ShouldEqual, 4.5) + So(res, ShouldEqual, 3.5) }) Convey("math.sqrt() works properly", t, func() { diff --git a/util/math/spread.go b/util/math/spread.go index 1de0bc2a..c0434041 100644 --- a/util/math/spread.go +++ b/util/math/spread.go @@ -36,6 +36,6 @@ func Spread(vals []float64) float64 { } } - return max - min + return (max - min) - 1 }