Java Convert BigInteger to BigDecimal
Tags: BigInteger BigDecimal
In this Java core tutorial we learn how to convert a java.math.BigInteger object to a java.math.BigDecimal object in Java programming language.
How to convert BigInteger to BigDecimal in Java
In Java, we can use the BigDecimal(BigInteger val) constructor to create a new BigDecimal object from a given BigInteger object as the following example Java code.
ConvertBigIntegerToBigDecimalExample1.java
import java.math.BigDecimal;
import java.math.BigInteger;
public class ConvertBigIntegerToBigDecimalExample1 {
public static void main(String... args) {
BigInteger bigIntegerValue = new BigInteger("111222333444555666777888999");
BigDecimal bigDecimalValue = new BigDecimal(bigIntegerValue);
System.out.println("BigInteger value: " + bigIntegerValue);
System.out.println("BigDecimal value: " + bigDecimalValue);
}
}
BigInteger value: 111222333444555666777888999
BigDecimal value: 111222333444555666777888999
Happy Coding 😊
Related Articles
Java Convert long to BigDecimal
Java Convert int to BigDecimal
Java Convert double to BigDecimal
Java Convert float to BigDecimal
How to use BigDecimal in Java by Examples
How to Add two BigDecimal values in Java
How to Subtract two BigDecimal values in Java
How to Multiply two BigDecimal values in Java
How to Divide two BigDecimal values in Java
Java Convert BigDecimal value into double value
Java Convert BigDecimal value into float value
Java Convert BigDecimal value into int value
Java Convert BigDecimal value into long value
Java Convert BigDecimal value into short value
Java Convert BigDecimal value to byte value
Java Convert BigDecimal to String
Java Convert String to BigDecimal
Java Compare two BigDecimal values
How to Negate BigDecimal Value in Java
How to Round BigDecimal Value in Java