I'm processing some floating point numbers, adding and subtracting them. This way I end up with numbers that are just a little (0.0000000000000001, 0.000000000000005, etc) off:
float_calc = [0.0]
float_calc.append(float_calc[0] + 0.000317)
float_calc.append(float_calc[1] + 0.000318)
float_calc.append(float_calc[2] - 0.000318)
float_calc.append(float_calc[3] + 0.000317)
print(float_calc)
# [0.0, 0.000317, 0.0006349999999999999, 0.00031699999999999995, 0.000634]
Is there anything I can do about this? How can I make sure that 0.000317 + 0.000318
comes out as 0.000634
0.000635
?