fixing power for non-negative integers

previous PR had merge conflicts. #8650