static long x ( long d , long m , long over ) { if ( d > over ) return Long . MAX_VALUE ; if ( d < - over ) return Long . MIN_VALUE ; return d * m ; }
Scale d by m checking for overflow . This has a short name to make above code more readable .