views:

83

answers:

3

Is there any way to convert a BigInteger into a BigDecimal? i know you can go from DEC to INT but i cant find a method to go the other way around in JAVA.

thanks in advance.

+7  A: 

You have a parameterized constructor for that.

BigDecimal(BigInteger val)

bdhar
It is customary to give credit when borrowing (or copying almost verbatim) from other's answers.
erickson
+3  A: 

There is a constructor for that.

BigDecimal bigdec = new BigDecimal(bigint);
erickson
thanks a mill!!!!!!!!!!!!!!
Regis
+2  A: 

BigDecimal public BigDecimal(BigInteger unscaledVal, int scale)Translates a BigInteger unscaled value and an int scale into a BigDecimal. The value of the BigDecimal is (unscaledVal/10scale).

Parameters: unscaledVal - unscaled value of the BigDecimal. scale - scale of the BigDecimal. Throws: NumberFormatException - scale is negative

Good luck!!!

Pragnesh Modh