Although, I don't like to use extensions as a crutch if there's a way to code something manually, so I'm curious to know what's wrong with my formula. I also tried converting it from radians to degrees (/180*pi) but it didn't help.
It could depend on what event you used that formula. Remember that your formula only works correctly on the first quadrant of the coordinate system. Atan always returns a value between -90 and +90.
Edit: Oh right, you should also stuff a *1.0 in everywhere, otherwise the division works with integers.