Menu Close

Go – How to get the error function of number in go

Here, We will learn how to get the error function of number in go. We can get it by using Erf() function in math package in go golang.

Function prototype:

func Erf(no float64) float64

Return value:

Erf() function in math package returns
the error function of number.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Erf(10)
  fmt.Printf("%0.2f\n", no)

  no = math.Erf(-1)
  fmt.Printf("%0.2f\n", no)

  no = math.Erf(0.25)
  fmt.Printf("%0.2f\n", no)

  no = math.Erf(200)
  fmt.Printf("%0.2f\n", no)
}

Output:

1.00
-0.84
0.28
1.00

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 *