I want to convert a String, lets say "abc"
, to an int with the corresponding ascii: in this example, 979899
.
I've run into two problems:
1) what I wrote only works for characters whose ascii is two characters long and
2) since these numbers get very big, I can't use longs and I'm having trouble utilizing BigIntegers.
This is what I have so far:
BigInteger mInt = BigInteger.valueOf(0L);
for (int i = 0; i<mString.length(); i++) {
mInt = mInt.add(BigInteger.valueOf(
(long)(mString.charAt(i)*Math.pow(100,(mString.length()-1-i)))));
}
Any suggestions would be great, thanks!