J3/03-155r1 To: J3 From: John Reid Subject: Treatment of signed zeros by ATAN2, LOG, and SQRT Date: 31 March 2003 Note: This is a replacement for J3/03-155. I have been persuaded by Bill Long not to propose edits that affect intrinsics other than these three. There is a small problem with the wording of the intrinsics ATAN2, LOG, and SQRT with respect to their treatment of signed zeros. The text was written before there was any thought of support for IEEE arithmetic and is fine for nonzero arguments. Wherever possible, the value for a signed zero should be the limit of those for small values of the same sign. For ATAN2(Y,X), there is a problem when X is negative. If Y is very small and positive, the result is near pi; if Y is very small and negative, the result is near -pi. It follows that if Y is plus zero, the result should be approximately pi and if Y is minus zero, the result should be approximately -pi. Unfortunately, the present wording says that the result is pi in both cases. There is a corresponding problem for the imaginary part of LOG(X) when X is complex with a negative real part. If the imaginary part of X is plus zero, the imaginary part of the result should be approximately pi and for minus zero, it should be approximately -pi. The present wording says that the result is pi in both cases. There is a similar problem for the imaginary part of SQRT(X) when X is complex with negative real part. If the imaginary part of X is small and positive, the imaginary part of the result should be positive and if it is small and negative, the imaginary part of the result should be negative. This should also be so for signed zeros, but the present wording says that the the imaginary part of the result is positive in both cases. I have also taken the opportunity to say that ATAN2(Y,X) has the value Y when Y=0 and X>0. The current wording says that the result is zero, which does not specify the sign. EDITS 3:20+. Add 3) If the processor can distinguish between positive and negative real zero, this standard requires different returned values for ATAN2(Y,X) when X < 0 and Y is negative real zero and for LOG(X) and SQRT(X) when X is complex with REAL(X) < 0 and negative zero imaginary part. 301:26. Replace < by <=. 301:27:28. Replace sentence 'If Y = 0, ...' by If Y = 0 and X > 0, the result is Y. If Y = 0 and X < 0, the result is pi if Y is positive real zero or the processor cannot distinguish between positive and negative real zero and -pi if Y is negative real zero. 324:14. Replace < by <=. 324:15:16. Replace sentence 'The imaginary part ...' by If the real part of X is less than zero and the imaginary part of X is zero, the imaginary part of the result is pi if the imaginary part of X is positive real zero or the processor cannot distinguish between positive and negative real zero and -pi if the imaginary part of X is negative real zero. 347:20:21. Replace 'is greater than or equal to zero' by 'has the same sign as the imaginary part of X'.