int binary_to_decimal(string binary_temp) { int two_to_the_power_of = binary_temp.length() - 1; int decimal_temp = 0; for (int i = 0; i < binary_temp.length(); i++) { if (binary_temp[i] == '1') { decimal_temp = decimal_temp + pow(2, two_to_the_power_of); } two_to_the_power_of--; } return decimal_temp; }