double rint(double x) { return floor(x + 0.5); }