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

How to solve BigDecimal exception in java

王林
Release: 2023-04-26 22:49:21
forward
1661 people have browsed it

1. Description

An exception occurred during division.

java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template