Adjust powerdecimal
to start from the highest valid power (currently one too high)
Change this:
while resultdecimal >= 2 ** powerdecimal:
powerdecimal += 1
To this:
while resultdecimal >= 2 ** powerdecimal:
powerdecimal += 1
powerdecimal -= 1