I'm trying to check if a sum of floating point numbers adds up to 100. And of course they don't, due to floating point accuracy.
So, what doesn't work is:
test = [99.9, 0.025, 0.025, 0.0125, 0.0125, 0.025]
sum(test) == 100.
alternatively
sum(test) > 99.99999 and sum(test) < 100.0000001
works fine, but I consider it as ugly, because the limits are arbitrary. Is there a more elegant method in python to check float numbers on equality? Or at least a method to choose the limits not only arbitrary but based on the internal accuracy?