It's worth noting that since that code only handles integral exponents, you might want to make pow a long int or something instead of a double.