How to use decimal floating point arithmetic and set the precision in Python

2 Answers

0 votes
from decimal import *

getcontext().prec = 6

print(Decimal(3) / Decimal(13))



'''
run:

0.230769

'''

 



answered Jun 7, 2019 by avibootz
0 votes
from decimal import *

getcontext().prec = 12

print(Decimal(3) / Decimal(13))



'''
run:

0.230769230769

'''

 



answered Jun 7, 2019 by avibootz
...