Convert - Parse decimal into binary in java

Binary Type:The Binary number system is another way to represent quantities. It is easy than the decimal system because it has only two digits (bits). The two binary digits are 1 and 0.Counting in Binary: Begin counting: 0, 1.If another digit is included then it will be like 10, 11.With three digit position you can continue to count as 100, 101, 110 and 111 and for fourth digit we will continue onwards.Conversion of decimal into binary number:Thejava.langpackage helps to convert adecimal number into a binary number.This program takes a decimal number and converts it into binary form using themethodtoBinaryString ().Buffered Readerreads text from an input stream and provides reading of characters, arrays, and lines. The buffer size can be fixed.Here is simple code to convert decimal into binary number.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);

}

}

This simple article tells that how we can convert decimal into binary number.

# Convert - Parse decimal into binary in java

by anonymous