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