English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++in2(x) function calculates the exponentiation of x to the base2base.
This function calculates the exponentiation of x to the base<cmath>defined in the header file.
2x = exp2(x)
double exp2(double x); float exp2(float x); long double exp2(long double x); double exp2(T x); //is of integer type
exp2function takes a single mandatory parameter (can be positive, negative, or 0).
exp2function returns[0, ∞]values within the range.
If the size of the result is too large to be represented by the return type value, the function will return HUGE_VAL with the correct sign and an overflow range error will occur.
#include <iostream> #include <cmath> using namespace std; int main() { double x = -6.19, result; result = exp2(x); cout << "exp2(x) = " << result << endl; return 0; }
When running the program, the output is:
exp2(x) = 0.013697
#include <iostream> #include <cmath> using namespace std; int main() { long int x = 14; double result; result = exp2(x); cout << "exp2(x) = " << result << endl; return 0; }
When running the program, the output is:
exp2(x) = 16384