La función complx.IsInf() en Golang informa si real(x) o imag(x) es un infinito. El valor devuelto es booleano.
Sintaxis:
func IsInf(x complex128) bool
Aquí, x es el conjunto de todos los números complejos con float64 partes reales e imaginarias.
Valor devuelto: Esto devuelve un valor booleano, ya sea verdadero o falso.
Ejemplo 1: Este ejemplo comprueba si 1+5i es infinito o no.
// Golang program to illustrate // the complx.IsInf() Function package main // importing fmt and math/cmplx import ( "fmt" "math/cmplx" ) // Calling Main() func main() { // creating a complex number 1 + 5i infy := complex(1, 5) // checking if it is infinity or not? fmt.Printf("%t", cmplx.IsInf(infy)) }
Producción:
false
Ejemplo 2: Este ejemplo verifica que el var infy es infinito o no.
// Golang program to illustrate // the complx.IsInf() Function package main // importing fmt and math/cmplx import ( "fmt" "math" "math/cmplx" ) // Calling Main method func main() { // creating infinity variable. inf := math.Inf(1) // creating infinity complex // number i.e. (INF + INFi) infy := complex(inf, inf) // checking if it is infinity. fmt.Printf("%t", cmplx.IsInf(infy)) }
Producción:
true
Publicación traducida automáticamente
Artículo escrito por PranchalKatiyar y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA