I have an array of Strings that represent Binary numbers (without leading zeroes) that I want to convert to their corresponding base 10 numbers. Consider:
bi
This might work:
public int binaryToInteger(String binary) { char[] numbers = binary.toCharArray(); int result = 0; for(int i=numbers.length - 1; i>=0; i--) if(numbers[i]=='1') result += Math.pow(2, (numbers.length-i - 1)); return result; }