Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Aug 7, 2023
Contribute to Docs

The Exp() function returns the value of e^x (e to the power of x), where x is the parameter.


import "math"

value := math.Exp(number)

Where value is the value of e raised to the power of number, and where number is a variable of type float64.

Special cases:

  • Exp(+Inf) returns +Inf
  • Exp(NaN) returns NaN as well (Not a Number)


The following code calculates the value of e to the power of 3, and prints the resulting value to the console.

package main
import (
func main() {
result := math.Exp(math.Inf(1))
fmt.Printf("%.1f\n", result)

The output will be:


Codebyte Example

The following code is runnable and demonstrates the use of the Exp() function.


All contributors

Looking to contribute?

Learn Go on Codecademy