Java program to print decimal number to binary

Java program to print decimal number to binary. In Java, convert a decimal number to a binary number. A decimal point separates the entire number from the fractional component, making decimals one of the forms of numbers. A binary number is a number represented in the base-2 numeral system or binary numeral system, which uses only two symbols: commonly “0” and “1” in mathematics and digital electronics.

public class Main
{ 
public static void main(String args[])
{ 
System.out.println(Integer.toBinaryString(5)); 
}
}

 

Output:

101

What is toBinaryString function in java program

The toBinaryString() method in java. lang. The integer package returns a string representation of the integer input as an unsigned integer in base 2. It takes an Int data-type argument and returns a binary string in return.

What is decimal value in java

A decimal number is defined as a number with a decimal point separating the full number and fractional parts. A decimal point is a dot in a decimal number. The digits after the decimal point represent a value less than one.

What is integer value in java

Integer, positive or negative whole-valued number, or 0. The integers are created using the counting numbers 1, 2, and 3 as well as the subtraction process. When you subtract a counting number from itself, the result is zero; for example, 4 4 = 0.