static int sign(double x) { ret x == 0.0 ? 0 : x < 0 ? -1 : 1; }