I have program which generates table which I need. When difference between numbers was enough large(about 5 points), everything was ok. So I decided to use Decimal library. But when I added that module to the program, everything was broken(numbers were the same). Here is my output(few start lines) with Decimal
0.00402787895809813677877597726251 0.00402787895809813677877597726251
0.00402787895809813677877597726251 0.00402787895809813677877597726251
0.00402787895809813677877597726251 0.00402787895809813677877597726251
As you can see they are the same, however base numbers are different. How to fix that bug?
from decimal import *
getcontext().prec = 30
ls = [1,4,2,1,1,1,2,1,1,1,1,1,1,1,1,2]
#N = Decimal(22)
l = Decimal(0.0040278789580981364238)
r = Decimal(0.0040278789580981370940)
one = Decimal(r-l)/Decimal(22)
print(len(ls))
for elem in ls:
print(Decimal(l),'\t',Decimal(l)+Decimal(one)*Decimal(elem))
l+=Decimal(one)*Decimal(elem)