View Single Post
Old Nov 21st, 2007, 8:57 PM   #21
null_ptr0
12 years old
 
Join Date: Nov 2007
Posts: 94
Rep Power: 1 null_ptr0 is on a distinguished road
Re: Decimal to binary help

An efficient, working, version of what I believe your objective is:
java Syntax (Toggle Plain Text)
  1. class BinaryTest {
  2. static String decimaleToBinaryString(int decimal) {
  3. return Integer.toBinaryString(decimal);
  4. }
  5.  
  6. public static void main(String... argv) {
  7. System.console.format("%s", decimalToBinaryString(Integer.parseInt(System.console().readLine("Please enter the decimal integer you would like to convert into a binary string: ")));
  8. }
  9. }

Last edited by null_ptr0; Nov 21st, 2007 at 9:17 PM.
null_ptr0 is offline   Reply With Quote