Java BigInteger.doubleValue()

Syntax

BigInteger.doubleValue() has the following syntax.

public double doubleValue()

Example

In the following code shows how to use BigInteger.doubleValue() method.


/*  www  .j  av a2s  .  c  o  m*/
import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    // assign value to bi1
    BigInteger bi1 = new BigInteger("123");

    // assign a larger value to bi2
    BigInteger bi2 = new BigInteger("12345678");

    // assign double value of bi1, bi2 to d1, d2
    Double d1 = bi1.doubleValue();
    Double d2 = bi2.doubleValue();

    System.out.println(d1);
    System.out.println(d2);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger