Learn and Learn

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

GoLang – Find 2 raise to Power x – Exp2() Function – Examples & Explanation

Exp2() function is used to find the 2 raise to the power x (base-2 exponential of x - 2**x) for the given input (x – parameter) in Go language.
The standard math package of Go programming language has Exp2() function. The purpose of this function is to find the base-2 exponential of x (2**x).

Syntax of Exp2() Function in Go Language

The syntax of Exp2() 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


Parameters of Exp2() 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) Exp2() 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 Exp2() Function in Go Language

Exp2() function will return 2**x, the base-2 exponential of x for the given input(x – parameter).


GoLang Exp2() Function Example 1



GoLang Exp2() Function Example 2



GoLang Exp2() Function Example 3



LearnAndLearn.com © 2018 - All rights reserved