In this post, we will see how to convert BigInteger toBigDecimal in java.
Using BigDecimal constructor
You can simply use BigDecimal’s following constructor to convert BigInteger to BigDecimal.
BigDecimal(BigInteger val)
Here is the complete example to convert BigInteger to BigDecimal in java.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
package org.arpit.java2blog; import java.math.BigDecimal; import java.math.BigInteger; public class BigDecimalToBigIntegerMain { public static void main(String[] args) { BigInteger bi=new BigInteger("10"); BigDecimal bd= new BigDecimal(bi); System.out.println("BigDecimal bd: "+bd.toString()); } } |
When you run above program, you will get below output:
BigDecimal bd: 10
That’s all about how to convert BigInteger to BigDecimal in java.
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.