Fastest raise to power.This tip submitted by Ezzetabi on 2005-03-18 16:31:04. It has been viewed 41403 times.Rating of 6.0 with 175 votes If you need raising to power some non standard object, like matrices or something overloaded with a integer exponent you can use this algorith: a any type that know operator*, b int (a*a)^(b/2) if b is even a^b = a*(a*a)*(int)^(b/2) if b is oddusing a recursive function your calculation will be faster (overall with big exponents) than the usual way. A little example code: More tips Help your fellow programmers! Add a tip! |