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 165 views
1 answer 248 views
1 answer 182 views
1 answer 194 views
2 answers 136 views
1 answer 156 views
...