>
> Juergen VonHagen wrote (little bits snipped for brevity)::
>
> >robin wrote:
> >>
> >> > From: Aleksandar Donev <[log in to unmask]>
> >>
> >> > I have a pedagological question for the Fortran teachers out there.
>
> Variants of this are not only useful for teachers, but also practitioners.
>
> >> > How does one write "best" an expression with mixed types, say:
> >> >
> >> > complex(kind=sp) :: x,y
> >> > integer :: k
> >> >
> >> > y=(k-1)/(k+1)*x
>
> If k is positive, the first part (integer arithmetic) is always 0, so y is 0
> If k is zero, y = -x
> If k is negative (except -1), y = 2.*x
I might be picky. The last one seems strange. My test has the
following results:
k (k-1)/(k+1)
-2 3
-3 2
-4 1
-5 1
. .
. .
Jing
--
________________________________ _-__-_-_ _-___---
Jing Guo, [log in to unmask], (301)614-6172(o), (301)614-6297(fx)
Data Assimilation Office, Code 910.3, NASA/GSFC, Greenbelt, MD 20771
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|