How do I implement this?
// round to the nearest double so that x + ref doesn't cause round off error
double round(double x, double ref) { }
So that
double x = ....;
double y = ....;
double x_new = round(x, y);
return x_new + y; // NO ROUND OFF!
In other terms (y + x_new) - x_new is strictly equal to y