Linux 常用C函数(常用数学函数篇2)
来源:互联网 发布:mysql怎么读 编辑:程序博客网 时间:2024/05/16 05:12
Linux 常用C函数(常用数学函数篇2)
2007-03-22 11:39
frexp(将浮点型数分为底数与指数)
相关函数
ldexp,modf表头文件
#include<math.h>定义函数
double frexp( double x, int *exp);函数说明
frexp()用来将参数x 的浮点型数切割成底数和指数。底数部分直接返回,指数部分则借参数exp 指针返回,将返回值乘以2 的exp次方即为x的值。返回值
返回参数x的底数部分,指数部分则存于exp指针所指的地址。附加说明
使用GCC编译时请加入-lm。范例
#include <math.h>main()
{
int exp;
double fraction;
fraction = frexp (1024,&exp);
printf("exp = %d/n",exp);
printf("fraction = %f/n", fraction);
}
执行
exp = 11fraction = 0.500000 /* 0.5*(2^11)=1024*/
ldexp(计算2的次方值)
相关函数
frexp表头文件
#include<math.h>定义函数
double ldexp(double x,int exp);函数说明
ldexp()用来将参数x乘上2的exp次方值,即x*2exp。返回值
返回计算结果。附加说明
使用GCC编译时请加入-lm。范例:
/* 计算3*(2^2)=12 */#include<math.h>
main()
{
int exp;
double x,answer;
answer = ldexp(3,2);
printf("3*2^(2) = %f/n",answer);
}
执行
3*2^(2) = 12.000000log(计算以e 为底的对数值)
相关函数
exp,log10,pow表头文件
#include <math.h>定义函数
double log (double x);函数说明
log()用来计算以e为底的x 对数值,然后将结果返回。返回值
返回参数x的自然对数值。错误代码
EDOM 参数x为负数,ERANGE 参数x为零值,零的对数值无定义。附加说明
使用GCC编译时请加入-lm。范例
#include<math.h>main()
{
double answer;
answer = log (100);
printf("log(100) = %f/n",answer);
}
执行
log(100) = 4.605170log10(计算以10 为底的对数值)
相关函数
exp,log,pow表头文件
#include<math.h>定义函数
double log10(double x);函数说明
log10()用来计算以10为底的x对数值,然后将结果返回。返回值
返回参数x以10为底的对数值。错误代码
EDOM参数x为负数。RANGE参数x为零值,零的对数值无定义。附加说明
使用GCC编译时请加入-lm。范例
#include<math.h>main()
{
double answer;
answer = log10(100);
printf("log10(100) = %f/n",answer);
}
执行
log10(100) = 2.000000pow(计算次方值)
相关函数
exp,log,log10表头文件
#include<math.h>定义函数
double pow(double x,double y);函数说明
pow()用来计算以x为底的y次方值,即xy值,然后将结果返回。返回值
返回x的y次方计算结果。错误代码
EDOM 参数x为负数且参数y不是整数。附加说明
使用GCC编译时请加入-lm。范例
#include <math.h>main()
{
double answer;
answer =pow(2,10);
printf("2^10 = %f/n", answer);
}
执行
2^10 = 1024.000000sin(取正玄函数值)
相关函数
acos,asin,atan,atan2,cos,tan表头文件
#include<math.h>定义函数
double sin(double x);函数说明
sin()用来计算参数x的正玄值,然后将结果返回。返回值
返回-1 至1之间的计算结果。附加说明
使用GCC编译时请加入-lm。范例
#include<math.h>main()
{
double answer = sin (0.5);
printf("sin(0.5) = %f/n",answer);
}
执行
sin(0.5) = 0.479426sinh(取双曲线正玄函数值)
相关函数
cosh,tanh表头文件
#include<math.h>定义函数
double sinh( double x);函数说明
sinh()用来计算参数x的双曲线正玄值,然后将结果返回。数学定义式为:(exp(x)-exp(-x))/2。返回值
返回参数x的双曲线正玄值。附加说明
使用GCC编译时请加入-lm。范例
#include<math.h>main()
{
double answer = sinh (0.5);
printf("sinh(0.5) = %f/n",answer);
}
执行
sinh(0.5) = 0.521095sqrt(计算平方根值)
相关函数
hypotq表头文件
#include<math.h>定义函数
double sqrt(double x);函数说明
sqrt()用来计算参数x的平方根,然后将结果返回。参数x必须为正数。返回值
返回参数x的平方根值。错误代码
EDOM 参数x为负数。附加说明
使用GCC编译时请加入-lm。范例
/* 计算200的平方根值*/#include<math.h>
main()
{
double root;
root = sqrt (200);
printf("answer is %f/n",root);
}
执行
answer is 14.142136tan(取正切函数值)
相关函数
atan,atan2,cos,sin表头文件
#include <math.h>定义函数
double tan(double x);函数说明
tan()用来计算参数x的正切值,然后将结果返回。返回值
返回参数x的正切值。附加说明
使用GCC编译时请加入-lm。范例
#include<math.h>main()
{
double answer = tan(0.5);
printf("tan (0.5) = %f/n",answer);
}
执行
tan(0.5) = 0.546302tanh(取双曲线正切函数值)
相关函数
cosh,sinh表头文件
#include<math.h>定义函数
double tanh(double x);函数说明
tanh()用来计算参数x的双曲线正切值,然后将结果返回。数学定义式为:sinh(x)/cosh(x)。返回值
返回参数x的双曲线正切值。附加说明
使用GCC编译时请加入-lm。范例
#include<math.h>main()
{
double answer = tanh(0.5);
printf("tanh(0.5) = %f/n",answer);
}
执行
tanh(0.5) = 0.462117- Linux 常用C函数(常用数学函数篇2)
- Linux 常用C函数(常用数学函数篇2)
- Linux 常用C函数(常用数学函数篇1)
- Linux 常用C函数(常用数学函数篇1)
- linux常用c函数 常用数学函数篇
- linux C 常用数学函数篇
- Linux C 函数参考之常用数学函数篇
- linux 常用数学函数
- 常用数学函数全集 Linux C
- Linux C Function()参考之常用数学函数篇
- c语言常用数学函数
- c语言常用数学函数
- object-c常用数学函数
- C/C++常用数学函数
- C语言常用数学函数
- C语言常用数学函数
- c语言常用数学函数
- Linux 常用C函数(用户组篇2)
- 三十六计第五计 趁火打劫
- datagrid数据导出到excel文件给客户端下载的几种方法
- Linux 常用C函数(常用数学函数篇1)
- .net工程师必懂题
- ASP中判断表达式是否数字的函数
- Linux 常用C函数(常用数学函数篇2)
- MATLAB学习笔记二
- 如何让你的SQL运行得更快!
- ASP.NET 2.0客户端回调的实现分析
- 三十六计第六计 声东击西
- Javascript技术技巧大全(一)
- 一道据说是世界上目前最好的智力题
- Linux 常用C函数(时间日期篇)
- 如何设置classpath