Atan2 Precision Problems

Your atan2 arguments are not valid in math sense, this function is not defined for both zeros.

Note that first argument should be r*sin(fi), the second one - r*cos(fi) for some angle fi and r>0

In dotnet rules are - note they assign 0in the 4th case, while one might expect NaN or some error:

For points on the boundaries of the quadrants, the return value is the following:

If y is 0 and x is not negative, θ = 0.
If y is 0 and x is negative, θ = π.
If y is positive and x is 0, θ = π/2.
If y is negative and x is 0, θ = -π/2.
If y is 0 and x is 0, θ = 0.

Your values fit to 5th and 3rd cases