Hi,
On Sun, 17 Sep 2000, Aleksandar Donev wrote:
> Hello,
>
> I have a pedagological question for the Fortran teachers out there.
> How does one write "best" an expression with mixed types, say:
...
> I recommend to students to explicitly write all the type conversions:
>
> y=cmplx(k-1,0,sp)/cmplx(k+1,0,sp)*x
The reason I don't like this sort of thing is that it makes the
reader look hard to see why the cast to complex is being done.
The only thing I would do for clarity is use parentheses so as
to indicate the appropriate groupings.
> though
>
> y=x*(k-1)/(k+1)
> also works
For this last, I would probably say something like:
y = (x*(k-1)) / (k+1)
-P.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|