As a rule of thumb, I never use equality against reals and doubles unless perhaps I round both sides first. An absolute difference might be better. Ex:

if (abs(x - y) < threashold) {....}