Index Home About Blog
From: corbett@lupa.Sun.COM (Robert Corbett)
Newsgroups: comp.lang.fortran
Subject: Re: What do you think?
Date: 23 Aug 2001 05:11:32 GMT

>"John Harper" <harper@mcs.vuw.ac.nz> wrote in message
>news:998518580.732661@bats.mcs.vuw.ac.nz...
>...
>> Is all this why 2.0**-2*-3 is not valid Fortran?
>> Mr Corbett's users presumably also use other languages that tempt
>> them to write such things; what happens in those?

The other languages involved here are vendor-extended versions of
Fortran.  One major vendor, which has since been bought out by Compaq,
added such an extension.  Since they were the defacto standard at the
time, the other major vendors had to copy their extensions to remain
competitive.

I have never understood why the people who added this extension thought

      2.0**-3*-2

should be equivalent to

      2.0**(-3*(-2))

but

      2.0**3*-2

should be equivalent to

      (2.0**3)*(-2)

					Sincerely,
					Bob Corbett


From: corbett@lupa.Sun.COM (Robert Corbett)
Newsgroups: comp.lang.fortran
Subject: Re: What do you think?
Date: 24 Aug 2001 04:13:01 GMT

In article <9lvhk3$e73$1@engnews1.eng.sun.com>,
 <corbett@lupa.eng.sun.com> wrote:
>Customers have asked us to support unary minus adjacent to binary
>operators.  What do you think the program
>
>      PROGRAM MAIN
>	PRINT *, 2.0**-2*-3
>      END
>
>should print?

The Fortran 95 team at Sun decided that there will be a compiler
option to allow unary minus following infix numeric operators,
but it will not be allowed by default.

I was surprised to discover that CVF treats X/-15*Y as X/(-15*Y),
but Sun's f77 compiler and the new code for Sun's f95 compiler
does the same.

				Sincerely,
				Bob Corbett

Index Home About Blog