The exp2()
function is used to return the base-2 exponential function of a given parameter value, x
.
Mathematically, exp2()
is given as follows:
exp2(x) =
Note: The base-2 exponential function simply means .
double exp2(double x);
float exp2(float x);
long double exp2(long double x);
This function takes a single parameter x
, which is a number that can be positive, negative, or zero.
The exp2()
function returns the value of numbers within 0 and ∞.
#include <iostream>#include <cmath>using namespace std;int main(){// creating our variablesdouble x = -5.5, result;// using the exp2() functionresult = exp2(x);cout << "exp2(-5.5) = " << result << endl;return 0;}
Line 9: We create the variables x
and result
.
Line 12: We implement the exp2()
function on the x
variable and assign the output to the result
variable.
Line 13: We print the result
variable.