A digit in input number must be less than number 's base
if ( val ( $ str [ $ i ] ) >= $ base ) { print ( " Invalid ▁ Number " ) ; return -1 ; } $ num += val ( $ str [ $ i ] ) * $ power ; $ power = $ power * $ base ; } return $ num ; }