Java convert BigInteger to double

Tags: BigInteger BigInteger doubleValue double

In this Java core tutorial we learn how to use the java.math.BigInteger.doubleValue() method to convert a BigInteger value to a double value.

How to convert BigInteger value to double value

To convert a BigInteger object to a double value we can use the java.math.BigInteger.doubleValue() method as the following Java example program.

ConvertBigIntegerToDoubleExample.java

import java.math.BigInteger;

public class ConvertBigIntegerToDoubleExample {
    public static void main(String... args) {
        BigInteger value = new BigInteger("123456");

        double doubleValue = value.doubleValue();

        System.out.println("BigInteger value: " + value);
        System.out.println("double value: " + doubleValue);
    }
}
The output is:
BigInteger value: 123456
double value: 123456.0

Happy Coding 😊