rhbartels@watcgl.UUCP (Richard Bartels) (12/20/84)
The following may need some explanation. A few days ago, Paul Schinder broadcast a general request to the net about raising negative reals and negative doubles to integer powers. I forwarded the request to Brian Smith of Argonne National Laboratory, who is the ACM-SIGNUM official representative on the IEEE X3J3 Committee (FORTRAN Standards). The following is his response, which he tried to forward directly to Paul, with a "destination unknown" result. The answer may have general interest. Furthermore: You should be aware that FORTRAN-77, and its standards, were set up by X3J3, whose members welcome general feedback. The committee is currently debating "FORTRAN 8x", proposals for a successor to FORTRAN-77. For details about the proposals as they now stand, the fall SIGNUM Newsletter can be consulted. (I could get a limited number of copies if you can't find them elsewhere. Oh, and memberships are welcomed.) Richard Bartels SIGNUM Chair Computer Science Department University of Waterloo Waterloo, Ontario N2L 3G1 CANADA --------------------------------------------------------------- Date: 19-Dec-84 11:28:38-CST (Wed) From: "Brian T. Smith" <watmath!ANL-MCS!smith> Subject: Interpretation of x**i, i<0 Return-Path: <smith@ANL-MCS.ARPA> To: paul@ANL-MCS@oddjob.UChicago Cc: SU-SCORE!na.bartels To: Paul Schinder Richard Bartels forwarded your message to me at Argonne. We are having problems with our net mail to certain locations, and so will mail this to Richard as well as you. Richard, please send a copy of this to Paul Schinder. Although the standard does not say so explicitly, I believe that it does require the interpretation of x**i where i is negative. The argument to support this view is that the standard appeals to the mathematical definition of raising x to the power y (as with other intrinsic operations such as sin, cos, etc.) to define the Fortran operation x**y. This appears in section 6.1.2 of the Fortran 77 standard. It goes on to say that once this interpretation in section 6.1.2 is established, then the processor may evaluate it in any mathematically equivalent fashion. (For example, x**i where i is negative and x is non-zero can be evaluated as 1.0/x**(-i).) It then goes on to say that wherever there is no mathematical definition, the operation is prohibited. These latter two statements appear in section 6.6 of the Fortran 77 standard. Therefore, given these statements, x**i where i is negative is mathematically defined (provided x is non-zero) and therefore must be evaluated (it does not say how accurately, though). As with all standards, the document is written in a concise but intended rigorous manner whose primary purpose is to define the language. Therefore, it does not always define constructs directly as in the above case. It appeals to more general definitions (mathematical concepts and models) that apply to many contexts (all intrinsic operations and intrinsic functions). By the way, I am a member of the current Fortran standards committee. The above comments are my best effort in trying to help you interpret the standard and what it says. This is therefore not an opinion from the Fortran committee. If you want, you can present this as a point of clarification for the committee, for which you will get an official response. Needless to say, as one of the contributors to the written document for the next standard, I will try to make sure that this is clarified in the next standard. The difficulty with trying to make a clear statement such as "Intrinsic operations (and intrinsic functions) must be evaluated for all operands (and arguments) for which they are mathematically defined" is that it does not address finite exponent ranges or asking for the sine of an argument that is extremely large and therefore the result has no meaning. If you want to discuss these remarks by phone, my number is 312-972-7232. Brian T. Smith Mathematics and Computer Science Division Argonne National Laboratory
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (12/26/84)
So how about an answer to the original question: x ** i where x is negative?
rhbartels@watcgl.UUCP (Richard Bartels) (12/28/84)
Sorry, Brian mixed i<0 for x<0, but the same answer should apply: "...the [FORTRAN 77] standard appeals to the mathematical definition of raising x to the power y..." since x**i is mathematically x*x*...*x (i times) for integer i>0 and (1/x)*(1/x)*...*(1/x) (-i times) for integer i<0 and x!=0 and is 1 for x!=0 and i=0, the standard in section 6.1.2 is implying that FORTRAN 77 should work for x<0 and integer i. If some particular compiler blows it, then it's the compiler which is at fault, and not the standard.