当前位置: C语言 -- 标准库 -- <math.h> -- exp2

exp2函数


概要:
#include <math.h>
double exp2(double x);

描述:

该函数是以2为基数的指数函数,计算2x的值。

如果参数x的值太大,将发生范围错误(range error)


参数:
double x

参数为一个double类型的浮点数。


返回值:

函数返回2x的值。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
/*函数exp2范例*/

#include <math.h>
#include <stdio.h>

int main(void)
{
    double x = 2.0;
    double y;

    y = exp2(x);
    printf("The base-2 exponential of %.6f is %.6f.\n", x, y);

    return 0;
}

输出:

The base-2 exponential of 2.000000 is 4.000000.


相关内容:
exp2f float类型的以2为基数的指数函数。
exp2l long double类型的以2为基数的指数函数。