Tuesday, March 11, 2008

Using the ^ operator that can slow your application down

I recently had an application where we used the "^" operation to do a Power operation.

For example in order to square X, we did X^2.  It turned out that using the "^" operator was slower than using X*X, or even using Math.Pow(X, 2).  It wasn't noticeably faster if you only did this once or twice, but in our situation, we called this function millions of times, so a little improvement made a big difference.

-- Ted

No comments: