summaryrefslogtreecommitdiff
path: root/src/pkg/cmath/isnan.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/cmath/isnan.go')
-rw-r--r--src/pkg/cmath/isnan.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pkg/cmath/isnan.go b/src/pkg/cmath/isnan.go
index 29b760135..8e971dbd3 100644
--- a/src/pkg/cmath/isnan.go
+++ b/src/pkg/cmath/isnan.go
@@ -6,9 +6,13 @@ package cmath
import "math"
-// IsNaN returns true if either real(x) or imag(x) is NaN.
+// IsNaN returns true if either real(x) or imag(x) is NaN
+// and neither is an infinity.
func IsNaN(x complex128) bool {
- if math.IsNaN(real(x)) || math.IsNaN(imag(x)) {
+ switch {
+ case math.IsInf(real(x), 0) || math.IsInf(imag(x), 0):
+ return false
+ case math.IsNaN(real(x)) || math.IsNaN(imag(x)):
return true
}
return false