101
Java BigDecimal intValueExact() Method
The intValueExact() method of java BigDecimal class is used to Convert a BigDecimal to an int type as well as this method also check for the lost information.
Syntax:
Parameter:
No
Exception:
If this has a non-zero fractional part, or will not fit in an int, then it throws an ArithmeticException.
Returns:
It returns int value from BigDecimal.
Example 1
Output:
Returned Exact Integer Value of 17674137 is = 17674137
Example 2
Output:
Returned Exact Integer Value of -623341 is = -623341
Example 3
Output:
ArithmeticException
Example 4
Output:
ArithmeticException
Next TopicJava BigDecimal