Techieindoor

Go – How to get exponential of number in go

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

Function prototype:

func Exp(no float64) float64

Return value:

Exp() function in math package returns the
e**no, the base-e exponential of number.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Exp(2)
  fmt.Printf("%.2f\n", no)

  no = math.Exp(1)
  fmt.Printf("%.2f\n", no)

  no = math.Exp(3)
  fmt.Printf("%.2f\n", no)

  no = math.Exp(0.75)
  fmt.Printf("%.2f\n", no)

}

Output:

7.39
2.72
20.09
2.12

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/
Exit mobile version