Mathprecision would control the number of decimal places, like numberformat, #.0000000000 would make the math be as good as ten decimal places allow it to be. Your routine for testing numbers that are very close was good, but that's just one example case of the issue. Doing something like n=int (n*10^p)/10^p would take care of the more general problem.