Given a particular value $a = \tan(x)$ there are two angles in the interval $(-\pi, \pi]$ or $[0, 2\pi)$ that have $a$ as their tangent. (See graph.)
To determine which angle, you'll need to look at which quadrant your point is in, and you can do this by inspection. Then, if you end up with an angle that doesn't make sense, you simply add or subtract $\pi$ to get it in the right quadrant.
Or, as suggested in the comments, you can use the "atan2" function that takes two arguments (thereby specifying the quadrant for you) and you'll get the right answer straight off.