Home » Java BigDecimal intValueExact() method with Examples

Java BigDecimal intValueExact() method with Examples

by Online Tutorials Library

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

Test it Now

Output:

Returned Exact Integer Value of 17674137 is = 17674137  

Example 2

Test it Now

Output:

Returned Exact Integer Value of -623341 is = -623341  

Example 3

Test it Now

Output:

ArithmeticException  

Example 4

Test it Now

Output:

ArithmeticException  

Next TopicJava BigDecimal

You may also like