如何从符号零摆脱减号 [英] How to get rid of minus sign from signed zero
本文介绍了如何从符号零摆脱减号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是用ASIN来计算的角度。在code是如下:
I am using asin to calculate the angle. The code is as below :
double FindAngle(const double theValue)
{
return asin(theValue);
}
FindAngle返回-0.0(符号零),当参数theValue = -0.0。现在,我要如何摆脱从返回值的减号。
FindAngle returns a -0.0 (signed zero), when the argument theValue = -0.0. Now, how do i get rid of the minus sign from the return value.
推荐答案
如果你只是想转换-0为0,并保留其他不变,只是做一个比较。
If you just want to convert -0 to 0 and leave other untouched, just do a comparison.
double FindAngle(double value) {
double res = asin(value);
if (res == 0.0) res = 0.0;
return res;
}
这篇关于如何从符号零摆脱减号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文