C语言中的求指函数
头文件
#include “math.h”
有以下三种内置求指函数
1、float powf( float base, float exponent );
2、double pow( double base, double exponent );
3、long double powl( long double base, long double exponent );
三种浮点精度对比
float :32位
double :64位
long double :128位
测试用例
#include <math.h>
#include <stdio.h>
int main()
{
float res_float = powf(10, 3.0/2);
double res_double = pow(10, 3.0 / 2);
long double res_longdouble = powl(10, 3.0 / 2);
printf("powf(10, 3.0/2)== %f \n", res_float);
printf("pow(10, 3.0/2)== %lf \n", res_double);
printf("powl(10, 3.0/2)== %lf \n", res_longdouble);
return 0;
}
3072

被折叠的 条评论
为什么被折叠?



