Package | Description |
---|---|
java.math |
Modifier and Type | Field and Description |
---|---|
static BigDecimal |
BigDecimal.ONE
The value 1, with a scale of 0.
|
static BigDecimal |
BigDecimal.TEN
The value 10, with a scale of 0.
|
static BigDecimal |
BigDecimal.ZERO
The value 0, with a scale of 0.
|
Modifier and Type | Method and Description |
---|---|
BigDecimal |
BigDecimal.abs()
Returns a
BigDecimal whose value is the absolute value of this BigDecimal , and whose scale is
this.scale() . |
BigDecimal |
BigDecimal.abs(MathContext mc)
Returns a
BigDecimal whose value is the absolute value of this BigDecimal , with rounding
according to the context settings. |
BigDecimal |
BigDecimal.add(BigDecimal augend)
Returns a
BigDecimal whose value is (this +
augend) , and whose scale is max(this.scale(),
augend.scale()) . |
BigDecimal |
BigDecimal.add(BigDecimal augend,
MathContext mc)
Returns a
BigDecimal whose value is (this + augend) , with rounding according to the context
settings. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor)
Returns a
BigDecimal whose value is (this /
divisor) , and whose preferred scale is (this.scale() -
divisor.scale()) ; if the exact quotient cannot be represented (because it has a non-terminating decimal
expansion) an ArithmeticException is thrown. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
int roundingMode)
Returns a
BigDecimal whose value is (this /
divisor) , and whose scale is this.scale() . |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
int scale,
int roundingMode)
Returns a
BigDecimal whose value is (this /
divisor) , and whose scale is as specified. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
int scale,
RoundingMode roundingMode)
Returns a
BigDecimal whose value is (this /
divisor) , and whose scale is as specified. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
MathContext mc)
Returns a
BigDecimal whose value is (this /
divisor) , with rounding according to the context settings. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
RoundingMode roundingMode)
Returns a
BigDecimal whose value is (this /
divisor) , and whose scale is this.scale() . |
BigDecimal[] |
BigDecimal.divideAndRemainder(BigDecimal divisor)
Returns a two-element
BigDecimal array containing the result of divideToIntegralValue followed by
the result of remainder on the two operands. |
BigDecimal[] |
BigDecimal.divideAndRemainder(BigDecimal divisor,
MathContext mc)
Returns a two-element
BigDecimal array containing the result of divideToIntegralValue followed by
the result of remainder on the two operands calculated with rounding according to the context settings. |
BigDecimal |
BigDecimal.divideToIntegralValue(BigDecimal divisor)
Returns a
BigDecimal whose value is the integer part of the quotient (this / divisor) rounded
down. |
BigDecimal |
BigDecimal.divideToIntegralValue(BigDecimal divisor,
MathContext mc)
Returns a
BigDecimal whose value is the integer part of (this / divisor) . |
BigDecimal |
BigDecimal.max(BigDecimal val)
Returns the maximum of this
BigDecimal and val . |
BigDecimal |
BigDecimal.min(BigDecimal val)
Returns the minimum of this
BigDecimal and val . |
BigDecimal |
BigDecimal.movePointLeft(int n)
Returns a
BigDecimal which is equivalent to this one with the decimal point moved n places to the
left. |
BigDecimal |
BigDecimal.movePointRight(int n)
Returns a
BigDecimal which is equivalent to this one with the decimal point moved n places to the
right. |
BigDecimal |
BigDecimal.multiply(BigDecimal multiplicand)
Returns a
BigDecimal whose value is (this ×
multiplicand), and whose scale is (this.scale() +
multiplicand.scale()) . |
BigDecimal |
BigDecimal.multiply(BigDecimal multiplicand,
MathContext mc)
Returns a
BigDecimal whose value is (this ×
multiplicand), with rounding according to the context settings. |
BigDecimal |
BigDecimal.negate()
Returns a
BigDecimal whose value is (-this) , and whose scale is this.scale() . |
BigDecimal |
BigDecimal.negate(MathContext mc)
Returns a
BigDecimal whose value is (-this) , with rounding according to the context settings. |
BigDecimal |
BigDecimal.plus()
Returns a
BigDecimal whose value is (+this) , and whose scale is this.scale() . |
BigDecimal |
BigDecimal.plus(MathContext mc)
Returns a
BigDecimal whose value is (+this) , with rounding according to the context settings. |
BigDecimal |
BigDecimal.pow(int n)
Returns a
BigDecimal whose value is (thisn), The power is computed exactly, to
unlimited precision. |
BigDecimal |
BigDecimal.pow(int n,
MathContext mc)
Returns a
BigDecimal whose value is (thisn). |
BigDecimal |
BigDecimal.remainder(BigDecimal divisor)
Returns a
BigDecimal whose value is (this % divisor) . |
BigDecimal |
BigDecimal.remainder(BigDecimal divisor,
MathContext mc)
Returns a
BigDecimal whose value is (this %
divisor) , with rounding according to the context settings. |
BigDecimal |
BigDecimal.round(MathContext mc)
Returns a
BigDecimal rounded according to the MathContext settings. |
BigDecimal |
BigDecimal.scaleByPowerOfTen(int n)
Returns a BigDecimal whose numerical value is equal to (
this * 10n). |
BigDecimal |
BigDecimal.setScale(int newScale)
Returns a
BigDecimal whose scale is the specified value, and whose value is numerically equal to this
BigDecimal 's. |
BigDecimal |
BigDecimal.setScale(int newScale,
int roundingMode)
Returns a
BigDecimal whose scale is the specified value, and whose unscaled value is determined by
multiplying or dividing this BigDecimal 's unscaled value by the appropriate power of ten to maintain its
overall value. |
BigDecimal |
BigDecimal.setScale(int newScale,
RoundingMode roundingMode)
Returns a
BigDecimal whose scale is the specified value, and whose unscaled value is determined by
multiplying or dividing this BigDecimal 's unscaled value by the appropriate power of ten to maintain its
overall value. |
BigDecimal |
BigDecimal.stripTrailingZeros()
Returns a
BigDecimal which is numerically equal to this one but with any trailing zeros removed from the
representation. |
BigDecimal |
BigDecimal.subtract(BigDecimal subtrahend)
Returns a
BigDecimal whose value is (this -
subtrahend) , and whose scale is max(this.scale(),
subtrahend.scale()) . |
BigDecimal |
BigDecimal.subtract(BigDecimal subtrahend,
MathContext mc)
Returns a
BigDecimal whose value is (this - subtrahend) , with rounding according to the context
settings. |
BigDecimal |
BigDecimal.ulp()
Returns the size of an ulp, a unit in the last place, of this
BigDecimal . |
static BigDecimal |
BigDecimal.valueOf(double val)
Translates a
double into a BigDecimal , using the double 's canonical string representation
provided by the Double.toString(double) method. |
static BigDecimal |
BigDecimal.valueOf(long val)
Translates a
long value into a BigDecimal with a scale of zero. |
static BigDecimal |
BigDecimal.valueOf(long unscaledVal,
int scale)
Translates a
long unscaled value and an int scale into a BigDecimal . |
Modifier and Type | Method and Description |
---|---|
BigDecimal |
BigDecimal.add(BigDecimal augend)
Returns a
BigDecimal whose value is (this +
augend) , and whose scale is max(this.scale(),
augend.scale()) . |
BigDecimal |
BigDecimal.add(BigDecimal augend,
MathContext mc)
Returns a
BigDecimal whose value is (this + augend) , with rounding according to the context
settings. |
int |
BigDecimal.compareTo(BigDecimal val)
Compares this
BigDecimal with the specified BigDecimal . |
BigDecimal |
BigDecimal.divide(BigDecimal divisor)
Returns a
BigDecimal whose value is (this /
divisor) , and whose preferred scale is (this.scale() -
divisor.scale()) ; if the exact quotient cannot be represented (because it has a non-terminating decimal
expansion) an ArithmeticException is thrown. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
int roundingMode)
Returns a
BigDecimal whose value is (this /
divisor) , and whose scale is this.scale() . |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
int scale,
int roundingMode)
Returns a
BigDecimal whose value is (this /
divisor) , and whose scale is as specified. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
int scale,
RoundingMode roundingMode)
Returns a
BigDecimal whose value is (this /
divisor) , and whose scale is as specified. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
MathContext mc)
Returns a
BigDecimal whose value is (this /
divisor) , with rounding according to the context settings. |
BigDecimal |
BigDecimal.divide(BigDecimal divisor,
RoundingMode roundingMode)
Returns a
BigDecimal whose value is (this /
divisor) , and whose scale is this.scale() . |
BigDecimal[] |
BigDecimal.divideAndRemainder(BigDecimal divisor)
Returns a two-element
BigDecimal array containing the result of divideToIntegralValue followed by
the result of remainder on the two operands. |
BigDecimal[] |
BigDecimal.divideAndRemainder(BigDecimal divisor,
MathContext mc)
Returns a two-element
BigDecimal array containing the result of divideToIntegralValue followed by
the result of remainder on the two operands calculated with rounding according to the context settings. |
BigDecimal |
BigDecimal.divideToIntegralValue(BigDecimal divisor)
Returns a
BigDecimal whose value is the integer part of the quotient (this / divisor) rounded
down. |
BigDecimal |
BigDecimal.divideToIntegralValue(BigDecimal divisor,
MathContext mc)
Returns a
BigDecimal whose value is the integer part of (this / divisor) . |
BigDecimal |
BigDecimal.max(BigDecimal val)
Returns the maximum of this
BigDecimal and val . |
BigDecimal |
BigDecimal.min(BigDecimal val)
Returns the minimum of this
BigDecimal and val . |
BigDecimal |
BigDecimal.multiply(BigDecimal multiplicand)
Returns a
BigDecimal whose value is (this ×
multiplicand), and whose scale is (this.scale() +
multiplicand.scale()) . |
BigDecimal |
BigDecimal.multiply(BigDecimal multiplicand,
MathContext mc)
Returns a
BigDecimal whose value is (this ×
multiplicand), with rounding according to the context settings. |
BigDecimal |
BigDecimal.remainder(BigDecimal divisor)
Returns a
BigDecimal whose value is (this % divisor) . |
BigDecimal |
BigDecimal.remainder(BigDecimal divisor,
MathContext mc)
Returns a
BigDecimal whose value is (this %
divisor) , with rounding according to the context settings. |
BigDecimal |
BigDecimal.subtract(BigDecimal subtrahend)
Returns a
BigDecimal whose value is (this -
subtrahend) , and whose scale is max(this.scale(),
subtrahend.scale()) . |
BigDecimal |
BigDecimal.subtract(BigDecimal subtrahend,
MathContext mc)
Returns a
BigDecimal whose value is (this - subtrahend) , with rounding according to the context
settings. |