Standard library / math

math.IsInf()

Tests infinity; positive sign tests +Inf, negative sign tests -Inf, zero tests either. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func IsInf(f float64, sign int) bool

Parameters & Attributes

NameTypeDescription
ffloat64Input floating-point value.
signintSign selector.

Return Value

bool

Tests infinity; positive sign tests +Inf, negative sign tests -Inf, zero tests either.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math")
func main() {  fmt.Println(math.IsInf(math.Inf(-1), 0))}
Go Reference