Please replace 1e-8 by DBL_EPSILON