I'm writing a bit of code in PyCharm, and I want the division to be much more accurate than it currently is (40-50 numbers instead of about 15). How Can I accomplish this?
Thanks.
Check out the decimal
module:
>>> from decimal import *
>>> getcontext().prec = 50
>>> Decimal(1)/Decimal(7)
Decimal('0.14285714285714285714285714285714285714285714285714')
If you're interested in more sophisticated operations than decimal
provides, you can also look at libraries like bigfloat
, or mpmath
(which I use, and like a lot.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With