In this section, you will learn how to convert a binary number into a decimal number. The java.lang package provides the facility to convert the integer data into the binary to decimal.
Code Description:
In this program, you will learn the use of parseLong() method. Define a class "BinaryToDecimal" using the parseLong() method. This method is used to parse the string argument as a signed decimal long. This method has been used for converting a long to a string and a String to a long.
Here is the code of this program:
import java.lang.*;
|
Output of this program:
| C:\corejava>java BinaryToDecimal Enter the Binary value: 10010 Decimal:=18 C:\corejava>_ |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Convert Binary to Decimal View All Comments
Post your Comment