Tuesday, April 30, 2013

Convert Decimal into Binary in Java


Converting decimal to binary in Java



import java.lang.*;
import java.io.*;
public class DecimalToBinary{
  public static void main(String args[]) throws IOException{
  BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  System.out.println("Enter the decimal value:");
  String hex = bf.readLine();
  int i = Integer.parseInt(hex);  
  String by = Integer.toBinaryString(i);
  System.out.println("Binary: " + by);
  }
}  


run:
Enter the decimal value:
10
Binary: 1010
BUILD SUCCESSFUL (total time: 9 seconds)

Other Way :


public class NumberConverter {
   public static void main(String[] args) {
       int i = Integer.parseInt(args[0]);
       toBinary(i);
   }

   public static void toBinary(int int1){
       System.out.println(int1 + " in binary is");
       System.out.println(Integer.toBinaryString(int1));
   }
}

-----------------------------------------------------

syntax - Converting decimal to binary in Java 
java - How to convert binary string value to decimal -
Converting Decimal to Binary Java 
java - Decimal-to-binary conversion
Java Program Convert Decimal To Binary
How to convert decimal to binary, octal and hex String in Java Program
Decimal To Binary Converter - Java Tutorials 
Negative decimal to binary - General Programming
decimal to binary number - Java Tutorials - Codecall
Convert Binary Integer to Decimal - Java Help
Searches related to java Convert Decimal into Binary
convert decimal number into binary
convert hexadecimal into binary
convert decimal into hexadecimal
convert fraction into binary
convert binary into octal
how to convert from base 10 to binary
binary converter to number
converting binary decimal calculator
how to convert decimal to binary - Java
Convert decimal value to binary 

1 comment:

  1. I have personally used “Pro Robot” before. But i lost my money trading on this program. A friend of mine he is also an expert trader. He suggested me Trend Trader. See it http://po.st/trendtrader
    . I am using this product since 3 weeks and i am getting good profit. Trend Trader always provide me right time signal to buy or sell. It's a great program for newbie trader. Also there is good option for trading. You can check it by visiting Trend Trader official site Trend Trader Official Website

    ReplyDelete