In applications (for example dealing with complex numbers) the pair (0., 0.) may be quite rare, but it is often inconvenient to guarantee that it will never occur. Hence I find that ArcTan2 is currently almost unuseable without calling it from within a "wrapper" function that tests for this case. This is ugly, inconvenient, and inefficient.

A far simpler solution is to simply remove the line

- Code: Select all
`ASSERT((y # 0) OR (x # 0), 20);`

Some comments that you might consider relevant:

1 - MATLAB allows (0., 0.), and returns 0.

2 - The alternative code at the bottom of the Math file allows (0., 0.), and returns 0.

I also propose removing the tests for INF, and thus further extending this function's domain. I accept that this situation probably occurs even less frequently, but removing these tests does no harm I can see, speeds up the function even more, and makes it align better with the IEEE 754 arithmetic standard.

One further comment about the alternative code: it returns the wrong sign when the y input = -0.