]> Cypherpunks repositories - gostls13.git/commitdiff
math/cmplx: make error tolerance test function of expected value
authorCharlie Dorian <cldorian@gmail.com>
Wed, 7 Oct 2015 03:16:47 +0000 (23:16 -0400)
committerIan Lance Taylor <iant@golang.org>
Wed, 7 Oct 2015 18:41:11 +0000 (18:41 +0000)
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>

src/math/cmplx/cmath_test.go

index f285646af7a8b9318b9decab32f93bde7dd6081b..18d9be819482504f32dfecca8b4650e7596c56c7 100644 (file)
@@ -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
                }