两个相等的计算不返回相同的结果
two equal calculations not returning the same result
我得到了两个不同的.cpp文件,两个相等的计算。但是它们不返回相同的结果吗?
一个代码
double theta = (double)maxLoc.y/angleBins*CV_PI;
std::cout << theta << " " << abs(sin(theta)) << std::endl;
一个结果
1.53589 0.999391
B 代码
double theta = (double)maxLoc.y / angleBins * CV_PI;
std::cout << theta << " " << abs(sin(theta)) << std::endl;
B 结果
1.53589 0
您可能在第二个代码片段中从 C 调用 abs
函数,该代码片段将int
作为参数。在两个代码片段(以及正确的标头#include<cmath>
)中使用std::abs
将解决问题。
相关文章:
- (C++)分析树以计算返回错误值的简单算术表达式
- 如何创建一个函数来计算并返回平均值、最大值和最小值
- 为什么是谷神星协方差.计算()似乎永远运行而不返回?
- 始终在 C++ 计算脚本中返回466750944
- imageLoad glsl 在计算着色器 OpenGL 4.3 中始终返回 0
- 返回一个计算了参数的函数
- 计算BST返回-1的高度混淆
- 我正在尝试创建一个布尔函数,该函数计算字符并在字符为"()*-+"时返回 true
- 计算 <Classtype*> 向量中所有项的布尔值的最有效方法,如果全部为真则返回 true
- 递归计算满足条件的值数并返回该数字
- 从捕获 constexpr 函数返回值的变量中删除 constexpr 会删除编译时计算
- 我正在尝试编写一个简单的计算程序,但答案一直返回为 0
- 为什么当我尝试计算平均绝对偏差时,我的程序返回 inf
- 为什么这个计算二进制搜索树中节点的递归函数总是返回比预期更大的结果
- 计算每秒添加到队列中添加的请求数 - 始终返回为零
- CSV文件中的两条线的交点的计算返回-1.#IND
- 如何在递归函数中计算返回结果
- R和C++中相同的计算返回不同的结果
- 是否有一种方法可以将子*返回到基数*并计算返回的子*是哪个?
- 简单的计算返回错误的值