atan2(0, -55) is different from atan2(-1*0, -55)
2 visualizzazioni (ultimi 30 giorni)
Steven Lord il 9 Set 2016
Numerically they are equal.
z = 0;
mz = -0;
z == mz
However, they are not identical.
Note that the sign bits are different. You can see this:
plusInf = 1/z
minusInf = 1/mz
As for how you can translate this to C++ ... why not just call std::atan2?
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.