osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can math.atan2 return INF?


On Wed, 22 Jun 2016 04:01 am, Pierre-Alain Dorange wrote:

> Steven D'Aprano <steve at pearwood.info> wrote:
> 
>> Are there any circumstances where math.atan2(a, b) can return an
>> infinity?
>> 
>> I know it will return a NAN under some circumstances.
> 
> atan or atan2 can't return INFINITE, it was the arc tangent of a value,
> then arc tangent can only be between -PI and +PI (is was an angle).

I should hope it wouldn't. That's why I'm asking.


> I do not know under what circumstance atan2 can return NAN, atan2 taks 2
> argument (y and x) and return the angle corresponding to y/x.
> If x is 0.0, atan2 return 0.0 (do not try to make the division).

py> math.atan2(NAN, 0)
nan

I think that the only way it will return a NAN is if passed a NAN.



-- 
Steven