That should work practically all the time on architectures such as x86 or
rs6k, but perhaps not on other architectures, when more than default real
precision is required of the division. I doubt the difference in efficiency
involved in changing the addition from integer to real will be noticed.
----- Original Message -----
From: "Jürgen v.Hagen" <[log in to unmask]>
To: "Comp Fortran" <[log in to unmask]>
Sent: Monday, October 02, 2000 12:37 AM
Subject: Re: Writing arithmetic expressions with mixed types
> robin wrote:
> >
> > > Date: Sun, 17 Sep 2000 11:54:36 -0400
> > > From: Aleksandar Donev <[log in to unmask]>
> >
> > > Hello,
> > >
> > > I have a pedagological question for the Fortran teachers out there.
> > > How does one write "best" an expression with mixed types, say:
> > >
> > > complex(kind=sp) :: x,y
> > > integer :: k
> > >
> > > y=(k-1)/(k+1)*x
> > >
>
> how about writing
>
> (k-1.)/(k+1.)
> ?
> juergen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|