Skip to content

Instantly share code, notes, and snippets.

@SIRHAMY
Created January 26, 2014 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SIRHAMY/8625995 to your computer and use it in GitHub Desktop.
Save SIRHAMY/8625995 to your computer and use it in GitHub Desktop.
Method that converts given string of positive integers into the integer primitive data type.
public static int strdtoi(String decimal)
{
int scalar = 1;
int result = 0;
for(int i=decimal.length()-1;i>=0;i--){
result += (decimal.charAt(i) - 48) * scalar;
scalar*=10;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment