Welcome to Kode Java

Kode Java website provides beginners to Java programming some examples to use the Java API (Application Programming Interface) to develop applications. Learning from some examples will hopefully decrease the time required to learn Java.

In this website you will find a lot of examples which grouped by the Java API package. You can easily find a solution to your problem. To help you learn more we have also setup a discussion forums where everyone can share their Java knowledge.

Enjoy your study, come and visit the site regularly to find more and more examples of Java code.

--
I Wayan Saryada
Kode Java Webmaster

How do I convert BigInteger into another radix number?

In this example you'll see how we can convert a BigInteger number into another radix such as binary, octal and hexadecimal.

package org.kodejava.example.math;

import java.math.BigInteger;

public class BigIntegerConversion {
    public static void main(String[] args) {
        BigInteger number = new BigInteger("2008");

        System.out.println("Number      = " + number);
        System.out.println("Binary      = " + number.toString(2));
        System.out.println("Octal       = " + number.toString(8));
        System.out.println("Hexadecimal = " + number.toString(16));

        number = new BigInteger("FF", 16);
        System.out.println("Number      = " + number);
        System.out.println("Number      = " + number.toString(16));
    }
}

The result of our examples:

Number      = 2008
Binary      = 11111011000
Octal       = 3730
Hexadecimal = 7d8
Number      = 255
Number      = ff
Can't find what you are looking for? Join our FORUMS and ask some questions!

Our Friends

Network Sites

Statistics

Locations of visitors to this page
eXTReMe Tracker
visitor stats
Ask an Expert - Visit my Virtual Office at LivePerson