Re: ^ formerly Re: POWER()

new topic     » goto parent     » topic index » view thread      » older message » newer message

First of all, we are talking about two different optimizations here.
The preproccesor replaces power (2, x) where x is small value, with fast
shift commands. (no multiplication occured) ..

So, actually, optimized are the 2 * 2 * 2 ... cases
You are talking about the x * x and the x * x * x cases
And now you requested a new operator for so we can optimize something we
needed a different operator for, to optimize.

power (object, atom)

If you pass an integer as the second argument, the preproccesor could
internally use a different, *faster* function for this.
If the atom is one, nothing should happen at all. (whole expression replaced
with the value of object) . If atom is between 2 and some small number, the
preproccesor could convert this to x * x * x ..  (just for those cases this
approuch would be faster)

I would gueess power () checks for these approuches either first, or does
some weird algebra with any kind of value you give it (how trivial it may
be) ..

I assume power () comes right out of the watcom toolbox. So you can bet, it
is pretty fast, and does eliminate trivial cases, it will asume the
c-programmer does.
In our world euphoria does this for us, and that should still be the case.

Robert, a simple optimization like this does not require a new operator,
does it ?
If not, can we assume this optimization will be implemented in the next
release ?

Ralf

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu