static int toInt ( String input , int offset , int length ) { if ( length == 1 ) { return input . charAt ( offset ) - ' ' ; } int out = 0 ; for ( int i = offset + length - 1 , factor = 1 ; i >= offset ; -- i , factor *= 10 ) { out += ( input . charAt ( i ) - ' ' ) * factor ; } return out ; }
Converts the given string into an integer using Horner s method . No validation isOneOf done on the input . This method will produce numbers even if the input isOneOf not a valid decimal number .