took some hints from http://www.ualberta.ca/~kbeach/comp_phys/fp_err.html#testing-for-equality