View Single Post
Old Nov 8th, 2007, 9:08 AM   #8
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Re: Decimal to binary help

You should use the return statement to return a string value from your method.

Let me know if this works. I didn't compile or test this code.
public static String decToBin(int decimal, String str)
{
	str += decimal % 2;
	decimal /= 2;
	if (decimal == 0) 
		return new StringBuffer(str).reverse().toString();
	else 
		return decToBin(decimal, str);
}
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote