a = 1.5
i = 0
k = 0.2
results = []
while True:
i += 1
results.append(k)
if k < a**i:
continue
elif k > a**i and k < 2 * a**1:
k = k - a**i
elif k > 2 * a**i:
k = k - 2 * a**i
else:
break
print(results)
This is a python code to solve a real-life math problem. When I ran it, terminal gave a traceback like this:
Traceback (most recent call last):
File "fusing.py", line 11, in <module>
if k < a**i:
OverflowError: (34, 'Result too large')
I found another question on stack overflow about the error. The accepted answer says that the OP can use the decimal library to fix it. I'm not sure whether I should use it or there are some other solutions to it. I'd be grateful if someone can tell me what to do.