hypot函数、fmod函数
看ros navigation里面的程序经常出现hypot这个函数,百度一番发现惊喜:摘抄别人博客如下:
一、hypot函数
C ++ hypot()函数 (C++ hypot() function)
hypot() function is a library function of cmath header, it is used to find the hypotenuse of the given numbers, it accepts two numbers and returns the calculated result of hypotenuse i.e. sqrt(x*x + y*y).
hypot()函数是cmath标头的库函数,用于查找给定数字的斜边,接受两个数字并返回斜边的计算结果,即sqrt(x * x + y * y) 。
Syntax of hypot() function:
hypot()函数的语法:
hypot(x, y); //(1)
Parameter(s): x, y – numbers to be calculated hypotenuse (or sqrt(x*x + y*y))
参数: x,y –要计算的斜边数(或sqrt(x * x + y * y) )
Return value: double – it returns double value that is the result of the expression sqrt(x*x + y*y).
返回值: double-它返回double值,该值是表达式sqrt(x * x + y * y)的结果 。
简化我们平时写得特别啰嗦的:
sqrt(pow(x, 2) + pow(y, 2));
还有这样的语法格式:
hypot(x, y, z); //等价与sqrt(pow(x,2) + pow(y,2) + pow(z,2))
二.fmod()函数
函数字面理解float mod (浮点数的模)
hypot()函数是math.h标头的库函数,#include <math.h>
fmod() 用来对浮点数进行取模(求余),其原型为: double fmod (double x, double y);
设返回值为 ret,那么 x = n * y + ret,其中 n 是整数,ret 和 x 有相同的符号,而且 ret 的绝对值小于 y 的绝对值。如果 x = 0,那么 ret = NaN。
fmod 函数计算 x 除以 y 的 f 浮点余数,这样 x = i*y + f,其中 i 是整数,f 和 x 有相同的符号,而且 f 的绝对值小于 y 的绝对值。
代码实例:
#include <stdio.h>
#include <math.h>
int main ()
{printf ( "fmod of 5.3 / 2 is %f\n", fmod (5.3,2) );printf ( "fmod of 18.5 / 4.2 is %f\n", fmod (18.5,4.2) );return 0;
}
输出结果:
fmod of 5.3 / 2 is 1.300000
fmod of 18.5 / 4.2 is 1.700000
hypot函数、fmod函数相关推荐
- c语言float可以 取余吗,C语言fmod()函数:对浮点数取模(求余)
头文件:#include fmod() 用来对浮点数进行取模(求余),其原型为: double fmod (double x); 设返回值为 ret,那么 x = n * y + ret,其中 n 是 ...
- C语言fmod()函数:对浮点数取模(求余)和%取余运算符的比较
头文件:#include <math.h> fmod() 用来对浮点数进行取模(求余),其原型为: double fmod (double x); 设返回值为 ret,那么 x = ...
- python使用numpy的np.fmod函数计算numpy数组除以某一特定数值剩余的余数(remainder)、np.mod函数和np.fmod函数对负值的处理方式有差异
python使用numpy的np.fmod函数计算numpy数组除以某一特定数值剩余的余数(remainder).np.mod函数和np.fmod函数对负值的处理方式有差异 目录
- fmod()函数和modf()函数
fmod()函数: 头文件:#include<math.h> C库函数... fmod()用来对浮点数进行取模(求余),原型为:float fmod(float x). 设x=k*n+h, ...
- fmod()函数、floor()函数、ceil()函数
fmod()函数:对浮点数进行取模(求余) Example: #include <stdio.h> #include <math.h>int main () {printf ( ...
- C++的 fmod 函数
在C++中,fmod()函数用于计算两个浮点数的模,它的原型如下: double fmod(double x, double y); fmod() 函数返回 x / y 的模,也就是余数. 以下是一个 ...
- c语言fmod函数_fmod()函数以及C ++中的示例
c语言fmod函数 C ++ floor()函数 (C++ floor() function) fmod() function is a library function of cmath heade ...
- c语言中fmod函数怎么用,调用fmod函数
1. 编译指示指令 C和C++的每个实现对它的主机或操作系统都支持一些独有的特征.例如,某些程序须对存放数据的存储器区域进行精确的控制,或必须控制特定函数接受参量的方式. #pragma指令对每个编译 ...
- 自己实现fmod函数
问题描述: 自己实现一个MyFmod函数,要和C语言库函数的fmod函数完成同样的功能. 问题分析: 首先我们要了解一下fmod函数它到底做了什么事情 (1) 函数原型 double fmod (do ...
最新文章
- python 图像分析自然纹理方向与粗细代码_python skimage图像处理(二)
- springboot集成mybatis-generator时候遇到的问题
- cxf开发Restful Web Services
- 修改Git提交者昵称和邮箱
- VTK:小部件之CompassWidget
- 动态规划算法的应用模型
- 10款交互设计原型开发工具(转)
- 截取字符串的函数_常用的Excel函数
- b g opencv读入的图片 r,OpenCV 读取摄像头并显示图像的R、G、B三个通道的直方图...
- 3.从Paxos到Zookeeper分布式一致性原理与实践---Paxos 工程实践
- 计算机实验报告protel,PROTEL_99SE实验报告
- 文件(夹)操作SHFileOperation (删除 复制 移动) 报错 无法读取源文件或磁盘
- vr转换软件android版,普通视频转换成VR
- 安卓数字倒数控件_大家有什么好用的安卓倒计时APP?
- 计算机中存储、网络传输计量单位
- 单样本学习(One shot learning)和孪生网络(Siamese Network)简介
- JavaScript删除节点
- Java语言与开发环境
- vue报错:vue.js:634 [Vue warn]: Cannot find element: #app
- vue页面跳转打开新的窗口