Path: utzoo!attcan!uunet!husc6!mailrus!uwmcsd1!vanvleck!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Unnecessary parenthesis Message-ID: <12281@mimsy.UUCP> Date: 2 Jul 88 08:13:29 GMT References: <326@marob.MASA.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 42 In article <326@marob.MASA.COM> daveh@marob.MASA.COM (Dave Hammond) writes: >Is different code produce by the compiler for "return n" and "return(n)" ? >How about "if (x>1 && y<2)" and "if ((x>1) && (y<2))" ? Do unnecessary >parenthesis generate more code ? For these expressions, one would hope not. On some machines, in certain expressions (including but not limited to floating point arithmetic), `unnecessary' parentheses may cause more code generation under dpANS rules: #define TWICE(x) ((x) + (x)) ... float p, q, r; ... r = TWICE(p + q); expands to r = ((p + q) + (p + q)); which might or might not be equivalent to r = p + p; r += q + q; and if this cannot be determined, must be compiled as r = p + q; r += p + q; /* more or less */ The important problem that is being solved is that a = (b + c) * d; might give 0.0 where a = (b * d) + (c * d); gives `floating point overflow'. Whether this is an ideal solution (or even a not-too-awful one) is another argument entirely.... -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris