###### 使用java.math.BigDecimal
public class BigDecimal
extends Number

BigDecimal 类使它的用户对舍入行为有完全的控制权，迫使用户显式地指定能够舍弃部分精度( (除法 和 setScale))的舍入操作的舍入行为。为达到该目的，该类提供了八个 舍入模式 。同时针对 BigDecimal 的精度操作提供了两种类型的操作：数值调整/舍入 (scaling/rounding)操作和小数点移动操作。Scaling/Rounding 操作 (SetScale) 返回一个 BigDecimal，其数值近似 (或精确) 等于操作数，其有效范围是指定的值；也就是说，它们以对数值产生最小影响的方式增加或减少精度。十进制小数点移动操作 (movePointLeft 和 movePointRight)返回一个 BigDecimal ，它是把操作数的小数点在指定方向移动一个指定距离产生的；这种操作可以改变一个数字的值但不影响它的精度。

public class BigDecimalextends Numberimplements Comparable Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a non-negative 32-bit integer scale, which represents the number of digits to the right of the decimal point. The number represented by the BigDecimal is (unscaledValue/10scale). BigDecimal provides operations for basic arithmetic, scale manipulation, comparison, hashing, and format conversion. The BigDecimal class gives its user complete control over rounding behavior, forcing the user to explicitly specify a rounding behavior for operations capable of discarding precision (divide(BigDecimal, int), divide(BigDecimal, int, int), and setScale(int, int)). Eight rounding modes are provided for this purpose. Two types of operations are provided for manipulating the scale of a BigDecimal: scaling/rounding operations and decimal point motion operations. Scaling/rounding operations (setScale) return a BigDecimal whose value is approximately (or exactly) equal to that of the operand, but whose scale is the specified value; that is, they increase or decrease the precision of the number with minimal effect on its value. Decimal point motion operations (movePointLeft(int) and movePointRight(int)) return a BigDecimal created from the operand by moving the decimal point a specified distance in the specified direction; that is, they change a number's value without affecting its precision. For the sake of brevity and clarity, pseudo-code is used throughout the descriptions of BigDecimal methods. The pseudo-code expression (i + j) is shorthand for "a BigDecimal whose value is that of the BigDecimal i plus that of the BigDecimal j." The pseudo-code expression (i == j) is shorthand for "true if and only if the BigDecimal i represents the same value as the the BigDecimal j." Other pseudo-code expressions are interpreted similarly. Note: care should be exercised if BigDecimals are to be used as keys in a SortedMap or elements in a SortedSet, as BigDecimal's natural ordering is inconsistent with equals. See Comparable, SortedMap or SortedSet for more information.

#### java.math.BigDecimal用法

2017-04-12 16:34:18

#### Java中的java.math.BigDecimal的使用

2013-06-11 18:45:03

#### java.lang.ClassCastException: java.math.BigDecimal错误

2012-02-16 19:18:12

#### 类型转换错误类似java.math.BigDecimal cannot be cast to java.lang.Double 解决办法

2017-07-27 11:36:25

#### Java对BigDecimal常用方法的归类 -计算机等级考试-考试吧

2010年10月23日 3KB 下载

#### java.math.BigDecimal cannot be cast to [Ljava.lang.Object;

2014-07-16 10:17:22

#### java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Long

2014-10-16 11:08:15

#### Hibernate反向工程关于java.math.BigDecimal替换

2015-02-28 18:42:07

#### java.math.BigDecimal cannot be cast to java.lang.String解决方法

2016-05-13 16:39:15

#### java.lang.ClassCastException:java.math.BigDecimal cannot be cast to java.lang.String

2014-12-31 21:17:55