1. ^ formerly Re: POWER()
>>>>>
when x*x returns the same value (int,atom,sequence) as
power(x,2) between 3 and 30 times faster...
ummmm sumfin wrong dontcha think?
<<<<<
Yeah, this caught my eye. Traditionally, we would _think_ of using power=
=2E
>>>>>
This request is simply the addition of the caret "^"
to the list of mathmatics operators for indicating
an object is to be raised to a power of.
<<<<<
I was thinking of that the other day. And you suggestion about leaving i=
t
to positive int's is good too. Robert?
--Alan
=
2. Re: ^ formerly Re: POWER()
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