如何使用 c++ 在 opencv 中对浮点数进行舍入
How to round float numbers in opencv with c++
我想在opencv中舍入一个浮点数(或双精度)我使用了这个,但是当使用 Qt 调试时,我让它指向这一行,所以我认为我的代码是错误的:
j2 = round((theta/steptetha)+501);
opencv 将双精度舍入到最接近的整数...但要小心,如果theta
和steptetha
是整数,则除法结果是整数...尝试类似这样的操作:
j2 = round( ((double)theta/steptetha)+501.0);
现在((double)theta/steptetha)
会给一个双倍
相关文章:
- 为什么我不能在不进行任何转换的情况下将浮点数放入任何类型的 ptr 中?
- 将大 int 转换为浮点数,而不舍入 c++
- 将浮点数舍入到一定精度
- 如何使用 c++ 在 opencv 中对浮点数进行舍入
- 浮点舍入不正确
- 将浮点数舍入为预定义点的常规网格
- 将浮点数转换为整数时如何舍入
- 将正浮点数组转换为无符号短数组,并按C++舍入
- 浮点舍入,将0.5舍入为0
- 浮点舍入
- 为什么在浮点数的末尾加上0会改变它的舍入方式(可能的GCC bug)
- 浮点数和由于舍入行为导致的不正确结果
- "floor"是否有可能由于浮点舍入误差而返回不准确的结果?
- GCC '-M32' 选项在不运行 Valgrind 时更改浮点舍入
- 在c++中使用不同的IEEE浮点舍入模式
- 更改浮点舍入模式
- 将双精度浮点数舍入到最接近且更大的浮点数
- 控制台计算器将浮点数推入堆栈时出现问题
- 浮点舍入误差
- 浮点-C++浮点舍入(错误?)