Is the correct answer from
sqrt( cmplx( -4.0, -0.0 ))
1. (0,-2)
2. (0,2)
3. both 1. and 2.
4. either 1. or 2. depending on the compiler flags
Different compilers give different results.
16-007r1:
Sec. 4.4.3.2p3 [56:21-25]:
"Processors that distinguish between positive and
negative zeros shall treat them as mathematically
equivalent ... as actual arguments to intrinsic
procedures other than those for which it is explicitly
specified that negative zero is distinguished".
Sec. 13.9.182p5 [424:7-8], SQRT(X):
"When the real part of the result is zero, the
imaginary part has the same sign as the imaginary
part of X".
Sec. 13.9.176 [422:7-8], SIGN(A,B):
"if the processor distinguishes between positive and
negative real zero, and B is negative real zero,
the value of the result is -|A|".
So SQRT does not explicitly specify that negative
zero is distinguished. However, does the word "sign"
in [424:8] mean as if intrinsic SIGN were applied
to determine the sign of the imaginary part of X?
SIGN does specify explicitly
that negative zero is distinguished.
So on processors which distinguish positive and
negative zero, SQRT *must* distinguish
negative and positive zero.
Does this mean that on such processors the
correct answer is only (1)?
On processors which do not distinguish
negative and positive zero, sign -0.0
is positive. So I guess that means the correct
answer must be only (2)?
Thanks
Anton
|