unary +
Gregory Smith
greg at utcsri.UUCP
Fri Mar 14 04:41:03 AEST 1986
In article <1147 at lsuc.UUCP> msb at 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
More information about the Comp.lang.c
mailing list