static double negateIf(bool negate, double x) { ret negate ? -x : x; }