Is there any way to convert a BigInteger
into a BigDecimal
?
I know you can go from a BigDecimal
to a BigInteger
, but I can't find a method to go the other way around in Java.
toBigInteger() converts this BigDecimal to a BigInteger. This conversion is analogous to the narrowing primitive conversion from double to long. Any fractional part of this BigDecimal will be discarded. This conversion can lose information about the precision of the BigDecimal value.
The main difference between the BigInteger and BigDecimal is that BigInteger supports arbitrary-precision integers and BigDecimal is for arbitrary-precision fixed-point numbers.
BigInteger is for integers (that is numbers without decimal point) You are trying to use it for working with floating numbers.
You have a parameterized constructor for that.
BigDecimal(BigInteger val)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With