unary +

KW Heuer kwh at bentley.UUCP
Thu Mar 13 01:18:28 AEST 1986


In article <1147 at lsuc.UUCP> lsuc!msb (Mark Brader) writes:
...
>	#define  ROUND(real)		((long) .5 + (real))
...
>There are, of course, NO unnecessary parentheses in the example.

True, they are necessary, but they are not sufficient.  If you want
ROUND to do what its name implies (for nonnegative arguments), you
should have written it
	#define	ROUND(real)		((long)(.5 + (real)))
since unary operators (including cast) have precedence over addition.
Just thought I should point that out, since you were otherwise being
quite careful with parens.



More information about the Comp.lang.c mailing list