PIC Microcontoller Basic Math Power Methods

Calculating x^y, 2^x, etc.

Code:

Theory:

x^y

If y is an integer, we can repeatedly multiply (or use even faster algorithms that repeatedly square and multiply).

If y is not an integer, we generally make the substitution

  x^y = e^(y ln( x ))
or
  x^y = 2^(y log2( x ))

and use some subroutine to calculate ln(x) and e^b -- or, alternatively, calculate log2(x) and 2^b.

(Is there a page somewhere on massmind describing logarithms and exponentials? Move the following text there.)

Questions: