Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

GoLang – Find Power of e in Form of e**x – Exp() Function – Examples & Explanation

Exp() function is used to find the power of e in the form of e**x for the given input (x – parameter) in Go language.
The standard math package of Go programming language has Exp() function. The purpose of this function is to find the base-e exponential of x (e**x). Where e is called Euler’s number, named after the renowned mathematician Leonhard Euler.

Syntax of Exp() Function in Go Language

The syntax of Exp() function in Go Language is:

Note: float64 is a data type in Go language which has IEEE-754 64-bit floating-point numbers.
Special cases are:
Exp(+Inf) = +Inf
Exp(NaN) = NaN

Note: Very large values overflow to 0 or +Inf. Very small values underflow to 1.

 

Parameters of Exp() Function in Go Language

x – Where x is any Valid float64 Input value. This parameter is required.

 

Error Handling

If the x parameter is not a number (numeric value) Exp() function returns an error .
If there is no argument (x – input value) passes to the function, then the compiler will produce an error.

 

Return Value of Exp() Function in Go Language

Exp() function will return the e**x, the base-e exponential of x of the given input(x – parameters).

 

GoLang Exp() Function Example 1


Output:
1.4462876036747396

 

Golang Exp() Function Example 2


Output:
0.36787944117144233

 

GoLang Exp() Function Example 3


Output:
6.565996913733051e+07

 

LearnAndLearn.com © 2018 - All rights reserved