cast Long to BigDecimal

You should not use BigDecimal d = new BigDecimal(long); !!

The implementation in BigDecimal for longs is not precise. For financial applications this is critical!

But the implementation for the String argument is better! So use something like:

new BigDecimal(yourLong.toString());

There was a talk on http://www.parleys.com/ about this.


You'll have to create a new BigDecimal.

BigDecimal d = new BigDecimal(long);

For completeness you can use:

// valueOf will return cached instances for values zero through to ten
BigDecimal d = BigDecimal.valueOf(yourLong);

0 - 10 is as of the java 6 implementation, not sure about previous JDK's