exp2
The C++
exp2()
function returns the base-2 exponential function. It is defined in the<cmath>
header file.
Syntax
exp2(x);
Parameters
The exp2()
function takes a one argument which can be any value i.e. negative, positive or zero.
Return value
Returns the value in the range of [0, ∞]
.
If the magnitude of the result is too large to be represented by a value of the return type, the function returns
HUGE_VAL
(orHUGE_VALF
orHUGE_VALL
) with the proper sign, and an overflow range error occurs.
exp 2
exp2() prototype [As of C++ 11 standard]
double exp2(double x); float exp2(float x); long double exp2(long double x); double exp2(T x); // For integral type
Example 1 : C++ exp2()
#include <stdio.h> #include <math.h> int main () { double param, result; param = 4.0; result = exp2(param); printf ("2 ^ %f = %f.\n", param, result ); return 0; }
Output
2 ^ 4.000000 = 16.000000.
exp 2 2
Example 2 : C++ exp2()
#include <iostream> #include <cmath> using namespace std; int main() { long int x = 11; double result; result = exp2(x); cout << "exp2(x) = " << result << endl; return 0; }
Output
exp2(x) = 2048