This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH]: Integrate gfortran with MPC
On Fri, May 29, 2009 at 10:39:20PM +0200, Tobias Burnus wrote:
> Summary: Try the C program with and without -fcx-fortran-rules; for
> details, see below.
>
> Tobias
>
>
> Steve Kargl wrote:
> > There appears to be a middle-end issue here as well. Consider,
> > the following program:
> >
> [...]
> > troutmask:sgk[205] ./z
> > NaN NaN NaN NaN
> > NaN NaN NaN NaN
> >
>
You probably already know this but for completeness,
the reason for the nan from gfortran is the definition
of complex division:
z1 / z2 = (x1 + i y1) / (x2 + i y2)
= (x1 + i y1) * (x2 - i y2) / (x2**2 + y2**2)
= (x1 * x2 + y1 * y2 + i (x2 * y1 - y2 * x1)) / (x2**2 + y2**2)
now, set x2 and y2 to zero:
z1 / z2 = (0 + i 0) / 0
= nan + i nan
I suppose one could argue that gfortran could do
z1 / z2 = ((x1 + i y1) / (x2**2 + y2**2)) * (x2 - i y2)
= (inf + i inf) * (0 - i 0)
A quick glance through IEEE754 doesn't give the result of
inf * 0, but nan is probably an acceptable choice.
--
Steve