Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!greg From: greg@utcsri.UUCP (Gregory Smith) Newsgroups: net.lang.c Subject: Re: unary + Message-ID: <2318@utcsri.UUCP> Date: Thu, 13-Mar-86 13:41:03 EST Article-I.D.: utcsri.2318 Posted: Thu Mar 13 13:41:03 1986 Date-Received: Thu, 13-Mar-86 13:48:25 EST References: <1227@mtx5a.UUCP> <1223@mit-eddie.MIT.EDU> <1147@lsuc.UUCP> Reply-To: greg@utcsri.UUCP (Gregory Smith) Distribution: net Organization: CSRI, University of Toronto Lines: 23 Summary: In article <1147@lsuc.UUCP> msb@lsuc.UUCP (Mark Brader) writes: > >People who don't think (a+b)+c, a+(b+c), and a+b+c should be >interchangeable with respect to optimization -- as they are and >will continue to be -- should consider this toy example: > > #define C_TO_F(temp) ((temp)*1.8 + 32) > #define JUST_ABOVE(temp) ((temp) + epsilon) /* extern epsilon */ > #define ROUND(real) ((long) .5 + (real)) > > scanf ("%d", &melt_pt); > desired_f_temp = ROUND (JUST_ABOVE (C_TO_F (melt_pt))); > >There are, of course, NO unnecessary parentheses in the example*. [example deleted, illustrating why C should be allowed to ignore ()'s in evaluating expressions] -But- ROUND(real) should be ((long)(.5+(real))). Casts are more bindish than +. So the example carries evan more weight. -- "So this is it. We're going to die." - Arthur Dent ---------------------------------------------------------------------- Greg Smith University of Toronto ..!decvax!utzoo!utcsri!greg