Java bigdecimal class longValueExact() method transforms bigdecimal value exactly in to exact long type values. Method throws NumberFormatException if it value other than a integer or double. And also throws an ArithmeticException when rounding is necessary. In the example four bigdecimal class objects namely: carel_0, carel_1, carel_2 & carel_3 respectively have been created.
In the example MathContext class object nc is created for rounding objects value.
In the example along with method generated result, original
bigdecimal value is also shown.
Syntax for using the method: public long longValueExact()
long ln = (this.object).longValueExact();
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: November 21, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles