isinf.mx raw

   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  
   5  package cmplx
   6  
   7  import "math"
   8  
   9  // IsInf reports whether either real(x) or imag(x) is an infinity.
  10  func IsInf(x complex128) bool {
  11  	if math.IsInf(real(x), 0) || math.IsInf(imag(x), 0) {
  12  		return true
  13  	}
  14  	return false
  15  }
  16  
  17  // Inf returns a complex infinity, complex(+Inf, +Inf).
  18  func Inf() complex128 {
  19  	inf := math.Inf(1)
  20  	return complex(inf, inf)
  21  }
  22