abs(计算整型数的绝对值)
相关函数 labs, fabs
表头文件 #include<stdlib.h>
定义函数 int abs (int j)
函数说明 abs()用来计算参数j的绝对值,然后将结果返回。
返回值 返回参数j的绝对值结果。
范例 #ingclude <stdlib.h>
main(){
int ansert;
answer = abs(-12);
printf("|-12| = %d\n", answer);
}
执行 |-12| = 12
acos(取反余弦函数数值)
相关函数 asin , atan , atan2 , cos , sin , tan
表头文件 #include <math.h>
定义函数 double acos (double x);
函数说明 acos()用来计算参数x的反余弦值,然后将结果返回。参数x范围为
-1至1之间,超过此范围则会失败。
返回值 返回0至PI之间的计算结果,单位为弧度,在函数库中角度均以弧度
来表示。
错误代码 EDOM参数x超出范围。
附加说明 使用GCC编译时请加入-lm。
范例 #include <math.h>
main (){
double angle;
angle = acos(0.5);
printf("angle = %f\n", angle);
}
执行 angle = 1.047198
asin(取反正弦函数值)
Untitled Document 页码,1/9
file://D:\linux_c\function\06.html 2004-1-9
相关函数 acos , atan , atan2 , cos , sin , tan
表头文件 #include <math.h>
定义函数 double asin (double x)
函数说明 asin()用来计算参数x的反正弦值,然后将结果返回。参数x范围为
-1至1之间,超过此范围则会失败。
返回值 返回-PI/2之PI/2之间的计算结果。
错误代码 EDOM参数x超出范围
附加说明 使用GCC编译时请加入-lm
范例 #include<math.h>
main()
{
double angle;
angle = asin (0.5);
printf("angle = %f\n",angle);
}
执行 angle = 0.523599
atan(取反正切函数值)
相关函数 acos,asin,atan2,cos,sin,tan
表头文件 #include<math.h>
定义函数 double atan(double x);
函数说明 atan()用来计算参数x的反正切值,然后将结果返回。
返回值 返回-PI/2至PI/2之间的计算结果。
附加说明 使用GCC编译时请加入-lm
范例 #include<math.h>
main()
{
double angle;
angle =atan(1);
printf("angle = %f\n",angle);
}
执行 angle = 1.570796
atan2(取得反正切函数值)
相关函数 acos,asin,atan,cos,sin,tan
表头文件 #include<math.h>
Untitled Document 页码,2/9
file://D:\linux_c\function\06.html 2004-1-9
定义函数 double atan2(double y,double x);
函数说明 atan2()用来计算参数y/x的反正切值,然后将结果返回。
返回值 返回-PI/2 至PI/2 之间的计算结果。
附加说明 使用GCC编译时请加入-lm。
范例 #include<math.h>
main()
{
double angle;
angle = atan2(1,2);
printf("angle = %f\n", angle);
}
执行 angle = 0.463648
ceil(取不小于参数的最小整型数)
相关函数 fabs
表头文件 #include <math.h>
定义函数 double ceil (double x);
函数说明 ceil()会返回不小于参数x的最小整数值,结果以double形态返回。
返回值 返回不小于参数x的最小整数值。
附加说明 使用GCC编译时请加入-lm。
范例 #include<math.h>
main()
{
double value[ ]={4.8,1.12,-2.2,0};
int i;
for (i=0;value[i]!=0;i++)
printf("%f=>%f\n",value[i],ceil(value[i]));
}
执行 4.800000=>5.000000
1.120000=>2.000000
-2.200000=>-2.000000
cos(取余玄函数值)
相关函数 acos,asin,atan,atan2,sin,tan
表头文件 #include<math.h>
定义函数 double cos(double x);
函数说明 cos()用来计算参数x 的余玄值,然后将结果返回。
Untitled Document 页码,3/9
file://D:\linux_c\function\06.html 2004-1-9
返回值 返回-1至1之间的计算结果。
附加说明 使用GCC编译时请加入-lm。
范例 #include<math.h>
main()
{
double answer = cos(0.5);
printf("cos (0.5) = %f\n",answer);
}
执行 cos(0.5) = 0.877583
cosh(取双曲线余玄函数值)
相关函数 sinh,tanh
表头文件 #include<math.h>
定义函数 double cosh(double x);
函数说明 cosh()用来计算参数x的双曲线余玄值,然后将结果返回。数学定义
式为:(exp(x)+exp(-x))/2。
返回值 返回参数x的双曲线余玄值。
附加说明 使用GCC编译时请加入-lm。
范例 #include<math.h>
main()
{
double answer = cosh(0.5);
printf("cosh(0.5) = %f\n",answer);
}
执行 cosh(0.5) = 1.127626
exp(计算指数)
相关函数 log,log10,pow
表头文件 #include<math.h>
定义函数 double exp(double x);
函数说明 exp()用来计算以e为底的x次方值,即ex值,然后将结果返回。
返回值 返回e的x次方计算结果。
附加说明 使用GCC编译时请加入-lm。
范例 #include<math.h>
main()
{
Untitled Document 页码,4/9
file://D:\linux_c\function\06.html 2004-1-9
double answer;
answer = exp (10);
printf("e^10 =%f\n", answer);
}
执行 e^10 = 22026.465795
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 = 11
fraction = 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()
Untitled Document 页码,5/9
file://D:\linux_c\function\06.html 2004-1-9
{
int exp;
double x,answer;
answer = ldexp(3,2);
printf("3*2^(2) = %f\n",answer);
}
执行 3*2^(2) = 12.000000
log(计算以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.605170
log10(计算以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()
{
Untitled Document 页码,6/9
file://D:\linux_c\function\06.html 2004-1-9
double answer;
answer = log10(100);
printf("log10(100) = %f\n",answer);
}
执行 log10(100) = 2.000000
pow(计算次方值)
相关函数 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.000000
sin(取正玄函数值)
相关函数 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);
}
Untitled Document 页码,7/9
file://D:\linux_c\function\06.html 2004-1-9
执行 sin(0.5) = 0.479426
sinh(取双曲线正玄函数值)
相关函数 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.521095
sqrt(计算平方根值)
相关函数 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.142136
Untitled Document 页码,8/9
file://D:\linux_c\function\06.html 2004-1-9
tan(取正切函数值)
相关函数 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.546302
tanh(取双曲线正切函数值)
相关函数 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
页Untitled Document 码,9/9
file://D:\linux_c\function\06.html 2004-1-9

转载于:https://www.cnblogs.com/masky5310/archive/2010/10/15/1852223.html

【转】常用数学函数篇(Linux c)相关推荐

  1. c++宏定义常量为什么使用移位_干货 | C语言系列3——常量,运算符,常用数学函数.........

    本期总结 1.符号常量和const常量: 2.运算符: 3.输入与输出: 4.常用数学函数. 往期回顾 干货 | C语言系列1--编程软件与做题平台 干货 | C语言系列2--程序结构与变量 符号常量 ...

  2. MATLAB常用数学函数

    MATLAB常用数学函数 l        三角函数和双曲函数 名称 含义 名称 含义 名称 含义 sin 正弦 csc 余割 atanh 反双曲正切 cos 余弦 asec 反正割 acoth 反双 ...

  3. C语言函数——常用数学函数

    该博文为原创文章,未经博主同意不得转载,如同意转载请注明博文出处 本文章博客地址:https://cplusplus.blog.csdn.net/article/details/104344326 常 ...

  4. python数学函数_「分享」关于Python整理的常用数学函数整理

    原标题:「分享」关于Python整理的常用数学函数整理 1.函数说明 abs(number)返回数字的绝对值,如abs(-10)返回10 pow(x,y[,z]) 返回x的y次幂(所得结果对z取模), ...

  5. 干货 | C语言系列3——常量,运算符,常用数学函数......

    符号常量和const常量 1.符号常量 符号常量通俗来讲就是"替换",又称为宏定义.格式如下: #define 标识符 常量 宏定义可以定义单个变量为常量,也可以定义某个语句或片段 ...

  6. iOS常用数学函数(公式)

    目录 常用数学函数 1 三角函数 2 反三角函数 3 双曲三角函数 4 指数与对数 5 取整 6 绝对值 7 标准化浮点数 8 取整与取余 9 其他 常见应用代码示例 数学常量 角度转弧度,弧度转角度 ...

  7. Pascal中的常用数学函数

    Pascal中的常用数学函数 1.求绝对值函数abs(x) 定义:function Abs(X): (Same type as parameter); 说明:X可以是整型,也可以是实型:返回值和X的类 ...

  8. Java常用数学函数总结及求数组的平均数、中位数和众数

    本篇博客总结了数学中常用的数学函数,同时给出了平均数.中位数.众数的求法,有没涉及到的欢迎补充或者留言我继续完善. package com.xlh.bd.internal.service; impor ...

  9. matlab 常用数学函数

    MATLAB常用的基本数学函数 abs(x):纯量的绝对值或向量的长度 angle(z):复数z的相角(Phase angle) sqrt(x):开平方 real(z):复数z的实部 imag(z): ...

最新文章

  1. sybase 数据导入mysql_Windows环境下Sybase12.5 数据库创建与导入数据库.docx
  2. Python--练习及面试题
  3. dropdownlist 实现无限级树形菜单
  4. mysql 5.6.14源码安装_CentOS 6.4下编译安装MySQL 5.6.14详细步骤
  5. 基于STM32F427的模拟SSI协议绝对式编码器位置反馈通信
  6. 汉仪尚巍手书_汉仪尚巍手书字体
  7. 百旺如何看是否清卡_清卡失败增值税未申报或未对比怎么办
  8. Linux服务器发包
  9. U盘重装Mac全新的操作系统详细教程
  10. 哪个邮箱好用?!TOM邮箱品牌测评分析
  11. 2021-11-24【数据结构练习题】【二叉搜索树的插入删除】
  12. [渝粤教育] 苏州农业职业技术学院 日语会话基础 参考 资料
  13. js 数组遍历时删除元素方法总结
  14. Java语言实现的各种排序
  15. 循环-求一个数各位数字的和
  16. The Tomcat connector configured to listen on port 8082 failed to start.启动web项目报错
  17. centos8使用技巧与阿贝云服务器
  18. c语言程序ax2 bx,计算ax2+bx+c程序清单计算机组成原理计算机系统概论.PPT
  19. 开源增强型zigbee协议栈
  20. 零基础无实物一步一步学PLCS7-1200仿真(八)-按键控制数码管显示

热门文章

  1. Capture images using V4L2 on Linux
  2. python批量访问网页保存结果_Python检测批量URL状态,并将返回正常的URL保存文件...
  3. 数据结构之平衡树:2-3查找树的介绍——16
  4. 怎样不停请求接口实现实时刷新_快狗打车实时数仓和基于Hologres的数据服务建设...
  5. 指令系统——数据寻址(3)——堆栈寻址(详解)
  6. 十三、CSS 3新特性详解(一)——属性、结构伪类、伪元素选择器,nth-child与nth-of-type区别,2D rotate,calc函数、滤镜filter、过渡transition
  7. python 全局变量、局部变量
  8. LeetCode 1786. 从第一个节点出发到最后一个节点的受限路径数(迪杰斯特拉 + 拓扑排序)
  9. 天池 在线编程 布尔表达式求值(栈)
  10. 04.卷积神经网络 W4.特殊应用:人脸识别和神经风格转换(作业:快乐屋人脸识别+图片风格转换)