Menu Close

Go – Inf() fucntion in math package in go

Here, We will learn about Inf() fucntion in math package in go.

Function prototype:

func Inf(sign int) float64

Return value:

Inf() function in math package returns
positive infinity if sign >= 0, negative

infinity if sign < 0.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Inf(1)
  fmt.Println(no)

  no = math.Inf(-2)
  fmt.Println(no)

  no = math.Inf(10)
  fmt.Println(no)

  no = math.Inf(-5)
  fmt.Println(no)

}

Output:

+Inf
-Inf
+Inf
-Inf

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, math

Leave a Reply

Your email address will not be published. Required fields are marked *