I want to know how to make floating-point equations correctly in Python3.
I am trying to solve a linear equation problem and have variables and statements below.
slope = float(70 / 23)
c = 9
(slope * -161) + c == -481 # False
print((slope * -161) + c) # -481.00000000000006
If you manually evaluate (slope * -161) + c
, you will get -481
. However, python evaluates it as -481.00000000000006
when I use float
. How do I resolve this issue?