public static long safeDivide ( long dividend , long divisor ) { if ( dividend == Long . MIN_VALUE && divisor == - 1L ) { throw new ArithmeticException ( "Multiplication overflows a long: " + dividend + " / " + divisor ) ; } return dividend / divisor ; }
Divides the dividend by the divisor throwing an exception if overflow occurs or the divisor is zero .