Okay, first explain how to do the conversion in words (not that I don't know, this will just help the recursive thinking).

This is good advice to always write some pseudocode first to get the basic algorithm on paper. Check out this wikipedia page for the example of converting binary to decimal and it is a near-recursive format already. Here is the link:

http://en.wikipedia....nary_SimplifiedOnce you have some psuedo code down, I have pasted a working recursive version of this program and function, take a look for one example on a way to solve this problem. By no means the optimal version, but tested and works. Also attached as a zip file.

import javax.swing.*;

import java.util.*;

import java.io.*;

import java.lang.Math;

public class binary_conv {

public static void main(String[] args) {

int binary = 101001;

System.out.println("binary = " + binary);

int decimal = binary2decimal(binary);

System.out.println("decimal = " + decimal);

}

public static int binary2decimal(int a){

String binary_str = a + "";

int current_power = binary_str.length() - 1;

if (current_power == 0) {

// Hit end of recursive chain, return the val of a * 2^0 == a

return a;

}

//current_val holds the calculation 2^current_power * (first binary digit)

int current_val = (int)Math.pow(2,current_power) * Integer.parseInt(binary_str.substring(0,1));

return current_val + binary2decimal(Integer.parseInt(binary_str.substring(1,binary_str.length())));

}

}