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

Related questions

1 answer 160 views
1 answer 239 views
1 answer 175 views
1 answer 186 views
2 answers 130 views
1 answer 151 views
...