Home  >  Article  >  Java  >  What is the role of BigDecimal in java

What is the role of BigDecimal in java

王林
王林forward
2023-05-05 17:13:071530browse

1. Description

The API class BigDecimal provided by Java in the java.math package is used to accurately calculate more than 16 significant digits. Double-precision floating-point variables can handle 16-bit significands, but in practical applications, larger or smaller numbers may need to be calculated and processed.

2. Example

        BigDecimal a =new BigDecimal(0.1);
        System.out.println("a values is:"+a);
        System.out.println("=====================");
        BigDecimal b =new BigDecimal("0.1");
        System.out.println("b values is:"+b);

What are the basic data types of java

The basic data types of Java 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 What is the role of BigDecimal 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