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 172 views
1 answer 254 views
1 answer 187 views
1 answer 198 views
2 answers 137 views
1 answer 158 views
...