Is there anyway to convert from double
value to BigInteger
?
double doubleValue = 64654679846513164.2; BigInteger bigInteger = (BigInteger) doubleValue;
I try to cast it but it didn’t work.
Advertisement
Answer
If you want to store the integral part of the double into a BigInteger
, then you can convert it into a BigDecimal
and then into a BigInteger
:
BigInteger k = BigDecimal.valueOf(doubleValue).toBigInteger();