double power(float number, float exponent) { if (exponent == 0) return 1;//Power of 0 is always 1 if (exponent == 1) return number;//Power of 1 is the number itself if (exponent < 0) return (1 / power(number,(-1 * exponent)));//power less than 0 makes it go to bottom of fraction (reciprecal)) if (exponent > 0 && exponent < 1) /*Um....fractional exponents...fractional exponents..... 12 ^ .25 is the same as the 4th root of 12....I don't know of any to the xth root function...if you know (lets say for this example we'll call it roots(float number, int toTheXthRoot), take the exponent, turn it into a fraction (you'll have to find/make a function for that, too), the top part of the fraction being the divisor, the bottom the denominator, you'll have to return roots(power(number, devisor), denominator);*/ return (number * power(number, exponent - 1);//12^3 == 12 * 12^2 == 12 * 12 * 12}
[Edit: It's no fun having to scroll several pages to the right to read a post]
[Edit: Let me have my fun..... ]
"I've learned something today: It doesn't matter if you're white, or if you're black...the only color that REALLY matters is green"
-Peter Griffin
Edited by - Oluseyi on February 17, 2002 5:09:50 PM
Edited by - matrix2113 on February 18, 2002 10:39:41 PM