Yes, and possibly the compiler version too,
and possibly the platform, etc.
For example on linux with ifort 16.0.2 20160204
I don't need to specify any compiler options:
implicit none
complex :: z1 = (-4.0, -0.0), z2 = (-4.0, 0.0)
write (*,*) log(z1), log(z2)
write (*,*) sqrt(z1), sqrt(z2)
write (*,*) exp(0.5 * log(z1)), exp(0.5 * log(z2))
end
The output:
(1.386294,-3.141593) (1.386294,3.141593)
(0.0000000E+00,-2.000000) (0.0000000E+00,2.000000)
(-8.7422784E-08,-2.000000) (-8.7422784E-08,2.000000)
Anyway, I believe these are the correct answers,
on a f08 conforming processor that distinguishes +0 and -0
(list directed output formatting, and floating point
precision issues aside).
The rules for LOG are the key, [394:31-395:3].
The standard uses the most mainstream
rules for the branch cut and the interpretation
of the -pi and +pi phases,
when +0 and -0 can be distinguished.
The SQRT rule "When the real part
of the result is zero, the imaginary
part has the same sign as the
imaginary part of X.", [424:7-8],
is just a consequence of the LOG rules.
My original question was
whether SQRT distinguishes -0.
[56:21-25] says "Processors that
distinguish between positive and
negative zero 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."
SQRT does not "explicitly specify"
that, so it appears that it does
not distinguish +0 and -0.
But this is incorrect, SQRT does
indeed distinguish +0 and -0
(again on processors which distinguish
+0 and -0). It must do this to be
consistent with LOG.
I suggest to replace
the last sentence of SQRT with
that which closely resembles the
last sentence of LOG.
I also think that "principal" in
[424:7] means the same as
"the real part greater than or equal to zero".
So this seems an unnecessary repetition.
I suggest to remove "principal" from [424:7].
So:
[424:6-8] replace "A result ... imaginary part of X."
with
"A result of type complex is the value with
the real part greater than or equal to zero.
If the real part of X is less
than zero and the imaginary
part of X is zero, then the
imaginary part of the result is
positive if the imaginary part of X
is positive real zero or the
processor does not distinguish
between positive and negative zero,
and negative if the imaginary
part of X is negative real zero."
Anton
|