diff options
| author | Charlie Dorian <cldorian@gmail.com> | 2015-10-06 23:16:47 -0400 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2015-10-07 18:41:11 +0000 |
| commit | 1ef9b5a5b90e6ea4dd5d9495cfe0d3d24446ff22 (patch) | |
| tree | fc8b345aed7b35d87a898378fa09cb382c3ecae6 /src | |
| parent | bf3bf092d1ae9b2b693b0326dcf36cf773853482 (diff) | |
| download | go-1ef9b5a5b90e6ea4dd5d9495cfe0d3d24446ff22.tar.xz | |
math/cmplx: make error tolerance test function of expected value
Copy math package CL 12230 to cmplx package.
Change-Id: I3345b782b84b5b98e2b6a60d8774c7e7cede2891
Reviewed-on: https://go-review.googlesource.com/15500
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/math/cmplx/cmath_test.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/math/cmplx/cmath_test.go b/src/math/cmplx/cmath_test.go index f285646af7..18d9be8194 100644 --- a/src/math/cmplx/cmath_test.go +++ b/src/math/cmplx/cmath_test.go @@ -438,8 +438,10 @@ func tolerance(a, b, e float64) bool { d = -d } - if a != 0 { - e = e * a + // note: b is correct (expected) value, a is actual value. + // make error tolerance a fraction of b, not a. + if b != 0 { + e = e * b if e < 0 { e = -e } @@ -460,8 +462,8 @@ func alike(a, b float64) bool { func cTolerance(a, b complex128, e float64) bool { d := Abs(a - b) - if a != 0 { - e = e * Abs(a) + if b != 0 { + e = e * Abs(b) if e < 0 { e = -e } |
