Edit: I am aware this question was already answered, I just didn't find it. Thanks to everyone who pointed me in the right direction.
Why is it that when I run the following code the answers are not 0?
a = .1
d = .3
x = - a - a - a + d
y = a + a + a - d
print(f'x is {x}')
print(f'x is {y}')
In other words -.1 - .1 - .1 + .3 and .1 + .1 + .1 - .3
Instead I get the following:
x is -5.551115123125783e-17
y is 5.551115123125783e-17
It's almost zero but it isn't zero.
Is this due to how the python language works, is it a hardware thing, or something else?
I can't seem to find anything on stack overflow concerning this and would really like to understand what is going on.