Java BigDecimal .toBigIntegerExact ()

Syntax

BigDecimal.toBigIntegerExact() has the following syntax.

public BigInteger toBigIntegerExact()

Example

In the following code shows how to use BigDecimal.toBigIntegerExact() method.


import java.math.BigDecimal;
import java.math.BigInteger;
//from  www . j a v  a  2  s  .c  o  m
public class Main {

     public static void main(String[] args) {
        BigDecimal bg1 = new BigDecimal("2426");
        // assign the BigIntegerExact value of bg1 to i1
        BigInteger i1 = bg1.toBigIntegerExact();

        System.out.println( "BigInteger value of " + bg1 + " is " + i1 );
    }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger