Results 1 to 5 of 5
Thread: Decimal to Binary
- 10-01-2011, 05:36 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 31
- Rep Power
- 0
Decimal to Binary
I need to develop a code that will convert decimal to binary....I have gotten stuck though on this certain part and was wonder
ing if any of you would be able to help see where my error is...
any help would be greatly appreciated !Java Code:public class binaryconvert { public static void main(String [] args) { int convert (int j) { int n=j; if (n==0) return 1; else{ convert(n/2); System.out.println(n%2); } } } }
- 10-01-2011, 05:59 PM #2
Senior Member
- Join Date
- Nov 2010
- Posts
- 210
- Rep Power
- 3
Re: Decimal to Binary
Do you have to write your own implementation, or can you use the Integer.toBinaryString() method?
You need to be returning something if n != 0.
- 10-01-2011, 06:06 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 31
- Rep Power
- 0
- 10-01-2011, 06:11 PM #4
Member
- Join Date
- Oct 2011
- Posts
- 33
- Rep Power
- 0
Re: Decimal to Binary
do you want to write function which prints binary version in String format or it should return binary value ?
- 10-01-2011, 06:24 PM #5
Member
- Join Date
- Mar 2011
- Posts
- 31
- Rep Power
- 0
Similar Threads
-
anyone know's how to program a conversion of binary-decimal , decimal-binary
By irnie1994 in forum JCreatorReplies: 5Last Post: 08-25-2011, 07:32 PM -
Decimal to binary, octal to decimal
By matejm1994 in forum New To JavaReplies: 3Last Post: 12-26-2010, 09:59 AM -
Binary to Decimal Converter
By c_walker in forum New To JavaReplies: 15Last Post: 11-24-2009, 02:38 PM -
Convert binary into decimal
By WarmRegards in forum New To JavaReplies: 8Last Post: 10-18-2009, 02:32 PM -
Eclipse- Decimal to binary
By queen_vee in forum New To JavaReplies: 1Last Post: 02-24-2009, 02:17 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks