Sign of infinity on division by zero
问题 I've implemented code to find the polar coordinates of a point in 2D space. if the point lies in the 1st or 2nd Quadrant, 0<=theta<=pi and if it lies in the 3rd or 4th Quadrant, -pi <= theta <= 0 . module thetalib contains real function comp_theta( x1, x2) implicit none real , intent(in) :: x1, x2 real :: x1p, x2p real :: x1_c=0.0, x2_c=0.0 real :: pi=4*atan(1.0) x1p = x1 - x1_c x2p = x2 - x2_c ! - Patch !if ( x1p == 0 .and. x2p /= 0 ) then ! comp_theta = sign(pi/2.0, x2p) !else ! comp_theta