Home >Java >javaTutorial >How to solve BigDecimal exception in java

How to solve BigDecimal exception in java

王林
王林forward
2023-04-26 22:49:211678browse

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)

What are the basic data types of java

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete