Power proposal for ANSI C -- we already have what we need
John Kessenich
jk at hpfelg.HP.COM
Tue Feb 2 02:17:34 AEST 1988
I have thought about using macros for squaring expressions, and problem
is that they *do* require a temp. This makes it impossible to do the
following:
#define SQR(exp) ????
x = y + z * SQR(a+b);
Either a temp must be available so one can write
#define SQR(exp) (t=(exp), t*t)
Or one must write
#define SQR(x,exp) {int t; t=(exp); x = t*t;}
which cannot be used in expressions.
Conclusion? there is not a good substitute for a real power operator.
(This does not mean there should be a power operator. :-)
---------------
John Kessenich
More information about the Comp.lang.c
mailing list