Thread Closed 
(-) 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."
Find all posts by this user
Thread Closed 


Messages In This Thread
(-) precedence - jhallen - 12-08-2022, 01:10 PM
RE: (-) precedence - Thomas Okken - 12-08-2022, 01:30 PM
RE: (-) precedence - jhallen - 12-08-2022, 01:47 PM
RE: (-) precedence - Matt Agajanian - 12-08-2022, 08:25 PM
RE: (-) precedence - Eddie W. Shore - 12-08-2022, 01:41 PM
RE: (-) precedence - Maximilian Hohmann - 12-08-2022, 02:21 PM
RE: (-) precedence - KeithB - 12-08-2022 02:38 PM
RE: (-) precedence - Maximilian Hohmann - 12-08-2022, 03:38 PM
RE: (-) precedence - KeithB - 12-08-2022, 04:01 PM
RE: (-) precedence - Thomas Okken - 12-08-2022, 05:43 PM
RE: (-) precedence - jhallen - 12-08-2022, 06:27 PM
RE: (-) precedence - Thomas Okken - 12-08-2022, 06:39 PM
RE: (-) precedence - jhallen - 12-08-2022, 06:49 PM
RE: (-) precedence - Albert Chan - 12-08-2022, 07:18 PM
RE: (-) precedence - Thomas Okken - 12-08-2022, 07:04 PM
RE: (-) precedence - Albert Chan - 12-08-2022, 07:33 PM
RE: (-) precedence - Massimo Gnerucci - 12-08-2022, 07:56 PM
RE: (-) precedence - Thomas Okken - 12-08-2022, 09:21 PM
RE: (-) precedence - Matt Agajanian - 12-08-2022, 09:47 PM
RE: (-) precedence - Matt Agajanian - 12-08-2022, 10:02 PM
RE: (-) precedence - Albert Chan - 12-09-2022, 04:02 PM
RE: (-) precedence - Thomas Okken - 12-08-2022, 10:23 PM
RE: (-) precedence - Matt Agajanian - 12-09-2022, 12:15 AM
RE: (-) precedence - KeithB - 12-09-2022, 02:52 PM
RE: (-) precedence - mfleming - 12-10-2022, 01:51 AM
RE: (-) precedence - rprosperi - 12-10-2022, 03:42 AM
RE: (-) precedence - Maximilian Hohmann - 12-10-2022, 04:18 PM
RE: (-) precedence - John Keith - 12-10-2022, 04:38 PM
RE: (-) precedence - toml_12953 - 12-10-2022, 05:57 PM
RE: (-) precedence - rprosperi - 12-10-2022, 06:56 PM
RE: (-) precedence - mfleming - 12-10-2022, 11:23 PM
RE: (-) precedence - John Keith - 12-10-2022, 10:22 PM
RE: (-) precedence - EdS2 - 12-11-2022, 08:29 AM
RE: (-) precedence - Maximilian Hohmann - 12-11-2022, 10:38 AM
RE: (-) precedence - mfleming - 12-11-2022, 01:27 PM
RE: (-) precedence - FLISZT - 12-12-2022, 04:37 PM
RE: (-) precedence - mfleming - 12-12-2022, 10:13 PM
RE: (-) precedence - FLISZT - 12-12-2022, 11:56 PM
RE: (-) precedence - David Hayden - 12-13-2022, 03:59 PM
RE: (-) precedence - Thomas Okken - 12-13-2022, 06:12 PM
RE: (-) precedence - Matt Agajanian - 12-19-2022, 08:56 PM
RE: (-) precedence - David Hayden - 12-21-2022, 12:08 AM
RE: (-) precedence - Albert Chan - 12-18-2022, 03:47 PM
RE: (-) precedence - KeithB - 12-19-2022, 06:28 PM
RE: (-) precedence - ijabbott - 12-13-2022, 07:37 PM
RE: (-) precedence - jhallen - 12-20-2022, 04:09 AM
RE: (-) precedence - Matt Agajanian - 12-20-2022, 05:48 AM
RE: (-) precedence - Matt Agajanian - 12-20-2022, 06:07 AM
RE: (-) precedence - Dan C - 12-21-2022, 06:29 PM
RE: (-) precedence - Matt Agajanian - 12-21-2022, 10:28 PM
RE: (-) precedence - Joe Horn - 12-22-2022, 03:03 AM
RE: (-) precedence - Matt Agajanian - 12-22-2022, 07:47 AM
RE: (-) precedence - Sukiari - 12-22-2022, 03:31 AM
RE: (-) precedence - Thomas Okken - 12-22-2022, 05:43 AM
RE: (-) precedence - Sukiari - 12-22-2022, 03:16 PM
RE: (-) precedence - Maximilian Hohmann - 12-22-2022, 05:46 PM
RE: (-) precedence - Sukiari - 12-23-2022, 05:11 AM
RE: (-) precedence - Thomas Okken - 12-23-2022, 07:16 AM
RE: (-) precedence - Sukiari - 12-25-2022, 11:46 PM
RE: (-) precedence - ijabbott - 12-26-2022, 09:43 AM
RE: (-) precedence - Albert Chan - 12-22-2022, 06:05 PM
RE: (-) precedence - Joe Horn - 12-22-2022, 01:25 PM
RE: (-) precedence - ijabbott - 12-22-2022, 09:17 PM
RE: (-) precedence - Albert Chan - 12-23-2022, 12:02 AM
RE: (-) precedence - Matt Agajanian - 12-23-2022, 06:04 AM
RE: (-) precedence - Albert Chan - 12-23-2022, 08:04 AM
RE: (-) precedence - toml_12953 - 12-23-2022, 10:32 AM
RE: (-) precedence - Thomas Okken - 12-23-2022, 03:54 PM
RE: (-) precedence - ijabbott - 12-23-2022, 07:40 PM
RE: (-) precedence - Thomas Okken - 12-23-2022, 07:54 AM
RE: (-) precedence - rprosperi - 12-26-2022, 01:21 AM
RE: (-) precedence - Thomas Okken - 12-26-2022, 06:11 AM
RE: (-) precedence - Sukiari - 12-26-2022, 03:25 PM
RE: (-) precedence - Thomas Okken - 12-26-2022, 06:10 PM
RE: (-) precedence - Eddie W. Shore - 12-26-2022, 03:55 PM
RE: (-) precedence - Sukiari - 12-26-2022, 08:50 PM
RE: (-) precedence - klesl - 12-26-2022, 09:42 PM
RE: (-) precedence - ijabbott - 12-26-2022, 10:54 PM
RE: (-) precedence - Eddie W. Shore - 12-27-2022, 01:33 AM
RE: (-) precedence - Matt Agajanian - 12-26-2022, 08:23 PM
RE: (-) precedence - Thomas Okken - 12-26-2022, 09:00 PM
RE: (-) precedence - Thomas Okken - 12-26-2022, 09:10 PM
RE: (-) precedence - rprosperi - 12-26-2022, 10:00 PM
RE: (-) precedence - FLISZT - 12-27-2022, 02:36 AM



User(s) browsing this thread: 3 Guest(s)