static long safeNegate(long val) { if (val == Long.MIN_VALUE) throw new ArithmeticException("long overflow"); ret -val; }