isinf.go 506 B

12345678910111213141516171819202122
  1. // Copyright 2010 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package cmplx
  5. import "math"
  6. // IsInf returns true if either real(x) or imag(x) is an infinity.
  7. func IsInf(x complex128) bool {
  8. if math.IsInf(real(x), 0) || math.IsInf(imag(x), 0) {
  9. return true
  10. }
  11. return false
  12. }
  13. // Inf returns a complex infinity, complex(+Inf, +Inf).
  14. func Inf() complex128 {
  15. inf := math.Inf(1)
  16. return complex(inf, inf)
  17. }