handling overflow test case
if ( base > Integer . MAX_VALUE / 10 || ( base == Integer . MAX_VALUE / 10 && str [ i ] - '0' > 7 ) ) { if ( sign == 1 ) return Integer . MAX_VALUE ; else return Integer . MIN_VALUE ; } base = 10 * base + ( str [ i ++ ] - '0' ) ; } return base * sign ; }