test down from the highest bit and accumulate the tentative value for valid bit 1 << 31 behaves incorrectly and gives Integer Min Value which should not be the case , instead 1L << 31 works correctly .
for ( int i = 31 ; i >= 0 ; -- i ) { if ( temp + ( divisor << i ) <= dividend ) { temp += divisor << i ; quotient |= 1L << i ; } }