BigDecimal
BigDecimal(BigInteger intVal, long val, int scale, int prec) {
this.*scale* = scale;
this.precision = prec;
this.*intCompact* = val;
this.*intVal* = intVal;
}
BigDecimal
构造器的参数是scale
、prec
什么呀??
😒
我去看一下官方的解释:
/**
* The scale of this BigDecimal, as returned by {@link #scale}.
*
* @serial
* @see #scale
*/
private final int scale; // Note: this may have any value, so
// calculations must be done in longs/**
* The number of decimal digits in this BigDecimal, or 0 if the
* number of digits are not known (lookaside information). If
* nonzero, the value is guaranteed correct. Use the precision()
* method to obtain and set the value if it might be 0. This
* field is mutable until set nonzero.
*
* @since 1.5
*/
private transient int precision;
scale
就是小数点后面的位数:小数点的精度
precision
就是整个的长度:整个对象的精度