Menu Close

Go – How to get base-e exponential of number minus 1 in go

Here, We will learn how to get base-e exponential of number minus 1 in go. We can get it by using Expm1() function in math package in go golang.

Function prototype:

func Expm1(no float64) float64

Return value:

Expm1() function in math package returns the
e**x - 1, the base-e exponential of x minus 1.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Expm1(0.09)
  fmt.Printf("%.3f\n", no)

  no = math.Expm1(0.01)
  fmt.Printf("%.3f\n", no)

  no = math.Expm1(1)
  fmt.Printf("%.3f\n", no)

  no = math.Expm1(-0.03)
  fmt.Printf("%.3f\n", no)

}

Output:

0.094
0.010
1.718
-0.030

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

https://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 *