I am working on a program that needs a high level of accuracy. Unfortunately when I run a simple code such as this:
65.2805151+66.5374849
the result is 131.81799999999998
Instead of a 131.818
How can I go about addressing this issue?
I am working on a program that needs a high level of accuracy. Unfortunately when I run a simple code such as this:
65.2805151+66.5374849
the result is 131.81799999999998
Instead of a 131.818
How can I go about addressing this issue?
You can work mpmath
which is a high precision package. Here's the link to its site
import mpmath as mp
a = 65.2805151
b = 66.5374849
mp.dps = 50
summation = [a,b]
print(mp.fsum(summation))
Output:
131.818