Java bigdecimal class intValueExact() method transforms
bigdecimal value exactly in to integer 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
objects namely: ganymede_0, ganymede_1, ganymede_2 & ganymede_3 respectively
have been created.
In the example MathContext class object mc is created for rounding the objects value.
In the example along with method generated result, original BigDecimal value is also shown.
Syntax for using the method: public int intValueExact()
System.out.println(bigdecimal_objectName.intValueExact());
or
int i = (this.object).intValueExact();
Java_BigDecimal_intValueExact.java
import java.math.BigDecimal;
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java BigDecimal intValueExact example
Post your Comment