Sorry, but I am not able to understand what exactly math.Exp
is doing in following code block:
package main
import (
"fmt"
"math"
)
func main() {
for x := 0; x < 8; x++ {
fmt.Printf("x = %f ex = %8.3f
", float64(x), math.Exp(float64(x)))
}
}
The output of the above program is:
x = 0.000000 ex = 1.000
x = 1.000000 ex = 2.718
x = 2.000000 ex = 7.389
x = 3.000000 ex = 20.086
x = 4.000000 ex = 54.598
x = 5.000000 ex = 148.413
x = 6.000000 ex = 403.429
x = 7.000000 ex = 1096.633
And, I am not able to understand what exactly is math.Exp
function is doing internally and converting float64(x)
to respective values as in the output. I have read the go
's official documentation, which says as below:
Exp returns e**x, the base-e exponential of x.
Reading which I am not very clear of the purpose and mechanism of math.Exp
function.
I am actually interested in what binary/mathematical operation is going under the hood.