Simplify and speed up dit.math.close