From: Charlie Dorian Date: Wed, 7 Oct 2015 03:16:47 +0000 (-0400) Subject: math/cmplx: make error tolerance test function of expected value X-Git-Tag: go1.6beta1~888 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1ef9b5a5b90e6ea4dd5d9495cfe0d3d24446ff22;p=gostls13.git 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 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot --- 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 }