(-) precedence
|
12-08-2022, 02:38 PM
(This post was last modified: 12-08-2022 02:39 PM by KeithB.)
Post: #6
|
|||
|
|||
RE: (-) precedence
Not a new problem!
From Kernighan and Plauger "The Elements of Programming Style": "A more insidious operator ambiguity occurs in this expression from an arctangent routine: TERM = TERM*(-X**2)/DENOM Is X negated and then squared, or squared and then negated? Fortran reference manuals seldom treat such fine points in detail; this may be a hard question to answer without running a test program. As a matter of fact the ANSI standard for Fortran calls for the latter interpretation (fortunate in this case) - the variable X is squared and then negated - but the line should still be rewritten as: TERM = -TERM * X**2 / DENOM The first form invites misunderstanding on the part of the reader, if not the compiler. Unless reader and compiler both understand the writer, the program is not communicating properly. [Rule of Thumb] Parenthesize to avoid ambiguity." |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)