Volatile constants?
Erik Mouw
J.A.K.Mouw@its.tudelft.nl
Wed Mar 29 10:05:00 GMT 2000
On Wed, 29 Mar 2000 18:49:04 +0100 (BST), Alasdair Baird wrote:
> > > #define abs2(x) (x<0 ? -x : x)
> >
> > <nitpick>
> > You should define this as:
> >
> > #define abs2(x) ((x) < 0 ? (-x) : (x))
> >
> > Rationale: see what happens with your version if you use abs2(2 - 3). The
> > extra parentesis enforce the correct operator precedence.
>
> I think that you might find the following to actually be correct though:
>
> #define abs2(x) ((x) < 0 ? -(x) : (x))
Yes, you're absolutely right.
Erik
--
In theory, practice and theory are the same, but in practice they
are different -- Larry McVoy
More information about the Gcc
mailing list