1. Description
An exception occurred during division.
java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result
When dividing by the divide method of BigDecimal, if the division is not integer and a cyclic decimal occurs, an exception will be thrown: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
2. Solution
divide method sets the precise decimal point, such as: divide(xxxxx,2)
Java's basic data types are divided into:
1. Integer type, used to represent the data type of integers.
2. Floating point type, a data type used to represent decimals.
3. Character type. The keyword of character type is "char".
4. Boolean type is the basic data type that represents logical values.
The above is the detailed content of How to solve BigDecimal exception in java. For more information, please follow other related articles on the PHP Chinese website!