A digit in input number must be less than number 's base
if ( val ( str [ i ] . charCodeAt ( ) ) >= b_ase ) { document . write ( " " ) ; return - 1 ; } num += val ( str [ i ] . charCodeAt ( ) ) * power ; power = power * b_ase ; } return num ; }