Added code to handle the case where the power is a negative integer.

Fixes #1068