Menu Close

Go – IsInf() fucntion in math package in go

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

Function prototype:

func IsInf(num float64, sign int) bool

Return value:

IsInf() function in math package gives
whether num is an infinity, according to sign.

There are three cases:
1: If sign > 0, IsInf gives whether num is
positive infinity.
2: If sign < 0, IsInf gives whether num is
negative infinity.
3: If sign == 0, IsInf gives whether num is
either infinity.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.IsInf(2, -1)
  fmt.Println(no)

  no = math.IsInf(-2.2, -10)
  fmt.Println(no)

  no = math.IsInf(-3, -1)
  fmt.Println(no)

  no = math.IsInf(3, 0)
  fmt.Println(no)

}

Output:

false
false
false
false

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.

Contact Us