non-built-in exponentiation (Re: What should be added to C)
VLD/VMB
gwyn at brl.arpa
Tue Jun 24 05:56:12 AEST 1986
I wrote
exponent % 2
because that was what I meant. If your compiler cannot optimize
expr % 2 == 0
to use a low-order bit test (two's complement only!), then perhaps
you should get somebody to improve your compiler. (The SVR2 VAX
PCC generates remarkably ugly code for this, by the way.)
I'm a software engineer, not a speed phreak; I prefer code to be
correct regardless of any particular machine architecture.
The algorithm I posted is so much more efficient than the "obvious"
method that concerns for microefficiency are relatively unimportant.
More information about the Comp.lang.c
mailing list