How do I Convert Decimal to Binary?

Bookmark this example!  
Category: java.lang, viewed: 1432 time(s).
 
package org.kodejava.example.java.lang;
 
public class IntegerToBinaryExample 
{
    public static void main(String[] args)
    {
        int integer = 127;
        String binary = Integer.toBinaryString(integer);
        System.out.println("Binary value of " + integer + " is " 
                + binary + ".");
        
        int original = Integer.parseInt(binary, 2);
        System.out.println("Integer value of binary '" + binary 
                + "' is " + original + ".");
    }
    
}
 
 

Here is the result of our program.

Binary value of 127 is 1111111.
Integer value of binary '1111111' is 127.
Can't find what you are looking for? Join our FORUMS and ask some questions!

Most Viewed Examples

Latest Code Examples

100 Top & Latest


Locations of visitors to this page
eXTReMe Tracker
visitor stats
Get Chitika Premium