When I run the below code in python3
a = 4.1
b = 1000000
c = 0
result = (a * b) + c
print(result)
I got this result
4099999.9999999995
Could you please tell me how to correct this calculation?
PS. This is a known issue in python?
When I run the below code in python3
a = 4.1
b = 1000000
c = 0
result = (a * b) + c
print(result)
I got this result
4099999.9999999995
Could you please tell me how to correct this calculation?
PS. This is a known issue in python?
this is a known behaviour on python2 but also python3.
The documentation suggests rounding the values or using the decimal module.