c++ – tan and infinity

Question:

Can tan return infinity? At what value? pi/2 does not return infinity (probably due to errors).

Answer:

No, tan cannot return infinity ( +Inf or -Inf ).

From a note on tan description in cppreference :

The function has poles at x = π(1/2 + n) , however existing implementations of floating point numbers cannot accurately represent π / 2, so the argument never hits a pole.

Scroll to Top