Go Exp2()
Published Aug 6, 2023
Contribute to Docs
The Exp2() function returns the value of a base-2 exponential of a given number of type float64.
Syntax
import math
result := math.Exp2(x)
Where result will contain the value of a base-2 exponential of x, returned as a float64.
Special cases:
- The result of
Exp2(+Inf)is +Inf - The result of
Exp2(NaN)is NaN
Example
The example below demonstrates the basic use of Exp2():
package mainimport ("fmt""math")func main() {x := 4.0result1 := math.Exp2(x)fmt.Printf("%.1f\n", result1)y := -4.0result2 := math.Exp2(y)fmt.Printf("%.1f\n", result2)}
The output will be:
16.00.1
Codebyte Example
The following example is runnable and shows how the Exp2() function handles special cases:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Go on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn how to use Go (Golang), an open-source programming language supported by Google!
- Beginner Friendly.6 hours