Are you comparing floating point numbers? Choosing a correct value for epsilon is impossible in the general case: https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/