This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: complex functions and exceptional values
On Thu, Jan 20, 2011 at 08:12:05PM -0800, Jerry DeLisle wrote:
> On 01/20/2011 03:34 PM, Steve Kargl wrote:
> >Do we have a program with complex function in gfortran?
> >Consider,
> >
> >troutmask:kargl[216] cat a.f90
> >program test
> > complex z
> > z = cmplx(100, 0)
> > print *, exp(z)
> >end program test
> >troutmask:kargl[217] gfortran -o z a.f90
> >troutmask:kargl[218] ./z
> > ( +Infinity, NaN)
> >
> >Yes, I know Inf and NaN are not address in the standard
> >unless one has the IEEE 754 intrinsic module. However,
> >the questions are what is the expected result and what
> >is the correct result for the above program. Noting
> >that mathematically, for z = x + I y, one has
> >
> >exp(z) = exp(x) * (cos(y) + I sin(y))
> >
> >and for any finite x, exp(x) is finite. A finite
> >number multiplied by zero is zero. So, one might
> >expect the output to be (+Inf, 0) instead of (+Inf, NaN).
> >
>
> As I see it, exp(100) evaluates to +Infinity. In the abstract world it is
> truly finite, but for our processor, its an overflow. +infinity x 0 is
> +Infinity?
>
Yes. I had to go re-read a draft of IEEE 754.
--
Steve