atan2(0, -55) is different from atan2(-1*0, -55)
2 次查看(过去 30 天)
显示 更早的评论
Just found that
>> atan2(0, -55)
ans =
3.1416
>> atan2(-1*0, -55)
ans =
-3.1416
I don't understand how is this possible? -1 *0 doesn't equal to 0?? How can I convert such behaviour to C++?
0 个评论
采纳的回答
Steven Lord
2016-9-9
Numerically they are equal.
z = 0;
mz = -0;
z == mz
However, they are not identical.
format hex
z
mz
Note that the sign bits are different. You can see this:
format
plusInf = 1/z
minusInf = 1/mz
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
...
If y is ±0 and x is negative or -0, ±π is returned
This is specifically called out in section 9.2.1 of IEEE 754-2008.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numbers and Precision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!