static int signWithThreshold(double x, double threshold) { if (threshold == 0 ? x == 0.0 : Math.abs(x) < threshold) ret 0; ret x < 0 ? -1 : 1; }