S - the scale metrics type associated with this Decimalpublic interface MutableDecimal<S extends ScaleMetrics> extends Decimal<S>
Decimal classes of different scales.
Mutable Decimals modify their state when performing arithmetic operations;
they represent the result after the operation. Arithmetic operations
therefore return this as return value. Note however that the
scale of a Mutable Decimal does not change and remains
constant throughout the lifetime of a MutableDecimal instance.
Mutable Decimals may be preferred over ImmutableDecimal descendants
e.g. if the allocation of new objects is undesired or if a chain of
operations is performed.
Mutable Decimals are NOT thread safe.
| Modifier and Type | Method and Description |
|---|---|
MutableDecimal<S> |
abs()
Returns a
Decimal whose value is the absolute value of this
Decimal. |
MutableDecimal<S> |
abs(OverflowMode overflowMode)
Returns a
Decimal whose value is the absolute value of this
Decimal. |
MutableDecimal<S> |
add(Decimal<?> augend,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this + augend). |
MutableDecimal<S> |
add(Decimal<?> augend,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this + augend). |
MutableDecimal<S> |
add(Decimal<S> augend)
Returns a
Decimal whose value is (this + augend). |
MutableDecimal<S> |
add(Decimal<S> augend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this + augend). |
MutableDecimal<S> |
add(double augend)
Returns a
Decimal whose value is (this + augend) after
converting the given double argument into a Decimal value of the
same scale as this Decimal. |
MutableDecimal<S> |
add(double augend,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this + augend) after
converting the given double argument into a Decimal value of the
same scale as this Decimal. |
MutableDecimal<S> |
add(long augend)
Returns a
Decimal whose value is (this + augend) after
converting the given long value to the scale of this
Decimal. |
MutableDecimal<S> |
add(long augend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this + augend) after
converting the given long value to the scale of this
Decimal. |
MutableDecimal<S> |
addSquared(Decimal<S> value)
Returns a
Decimal whose value is
(this + value2). |
MutableDecimal<S> |
addSquared(Decimal<S> value,
RoundingMode roundingMode)
Returns a
Decimal whose value is
(this + value2). |
MutableDecimal<S> |
addSquared(Decimal<S> value,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is
(this + value2). |
MutableDecimal<S> |
addUnscaled(long unscaledAugend)
Returns a
Decimal whose value is
(this + unscaledAugend × 10-scale) with the
scale of this Decimal. |
MutableDecimal<S> |
addUnscaled(long unscaledAugend,
int scale)
Returns a
Decimal whose value is
(this + unscaledAugend × 10-scale). |
MutableDecimal<S> |
addUnscaled(long unscaledAugend,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is
(this + unscaledAugend × 10-scale). |
MutableDecimal<S> |
addUnscaled(long unscaledAugend,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is
(this + unscaledAugend × 10-scale). |
MutableDecimal<S> |
addUnscaled(long unscaledAugend,
OverflowMode overflowMode)
Returns a
Decimal whose value is
(this + unscaledAugend × 10-scale) with the
scale of this Decimal. |
MutableDecimal<S> |
avg(Decimal<S> val)
Returns the average of this
Decimal and val. |
MutableDecimal<S> |
avg(Decimal<S> val,
RoundingMode roundingMode)
Returns the average of this
Decimal and val. |
MutableDecimal<S> |
clone()
Returns a clone of this mutable Decimal numerically identical to this
value.
|
MutableDecimal<S> |
divide(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S> |
divide(Decimal<S> divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S> |
divide(Decimal<S> divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S> |
divide(double divisor)
Returns a
Decimal whose value is (this / divisor) after
converting the given double argument into a Decimal value of the
same scale as this Decimal. |
MutableDecimal<S> |
divide(double divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor) after
converting the given double argument into a Decimal value of the
same scale as this Decimal. |
MutableDecimal<S> |
divide(long divisor)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S> |
divide(long divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S> |
divide(long divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S>[] |
divideAndRemainder(Decimal<S> divisor)
Returns a two-element
Decimal array containing the result of
divideToIntegralValue followed by the result of remainder
on the two operands. |
MutableDecimal<S>[] |
divideAndRemainder(Decimal<S> divisor,
OverflowMode overflowMode)
Returns a two-element
Decimal array containing the result of
divideToIntegralValue followed by the result of remainder
on the two operands. |
MutableDecimal<S> |
divideBy(Decimal<?> divisor)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S> |
divideBy(Decimal<?> divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S> |
divideBy(Decimal<?> divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
MutableDecimal<S> |
divideByPowerOfTen(int n)
Returns a
Decimal whose value is (this / 10n)
. |
MutableDecimal<S> |
divideByPowerOfTen(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / 10n)
. |
MutableDecimal<S> |
divideByPowerOfTen(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / 10n)
. |
MutableDecimal<S> |
divideExact(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor),
checking for lost information. |
MutableDecimal<S> |
divideToIntegralValue(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor) rounded
down to the next integer. |
MutableDecimal<S> |
divideToIntegralValue(Decimal<S> divisor,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this / divisor) rounded
down to the next integer. |
MutableDecimal<S> |
divideTruncate(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor) rounded
down. |
MutableDecimal<S> |
divideUnscaled(long unscaledDivisor)
Returns a
Decimal whose value is
(this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
MutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
int scale)
Returns a
Decimal whose value is
(this / (unscaledDivisor × 10-scale)). |
MutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is
(this / (unscaledDivisor × 10-scale)). |
MutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is
(this / (unscaledDivisor × 10-scale)). |
MutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is
(this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
MutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is
(this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
MutableDecimal<S> |
fractionalPart()
Returns a
Decimal whose value represents the fractional part of
(this) value. |
MutableDecimal<S> |
integralPart()
Returns a
Decimal whose value represents the integral part of
this Decimal. |
MutableDecimal<S> |
invert()
Returns a
Decimal whose value is (1 / this). |
MutableDecimal<S> |
invert(RoundingMode roundingMode)
Returns a
Decimal whose value is (1 / this). |
MutableDecimal<S> |
invert(TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (1 / this). |
MutableDecimal<S> |
max(MutableDecimal<S> val)
Returns the maximum of this
Decimal and val. |
MutableDecimal<S> |
min(MutableDecimal<S> val)
Returns the minimum of this
Decimal and val. |
MutableDecimal<S> |
multiply(Decimal<S> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiply(Decimal<S> multiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiply(Decimal<S> multiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiply(double multiplicand)
Returns a
Decimal whose value is (this * multiplicand)
after converting the given double argument into a Decimal value
of the same scale as this Decimal. |
MutableDecimal<S> |
multiply(double multiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * multiplicand)
after converting the given double argument into a Decimal value
of the same scale as this Decimal. |
MutableDecimal<S> |
multiply(long multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiply(long multiplicand,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiplyBy(Decimal<?> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiplyBy(Decimal<?> multiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiplyBy(Decimal<?> multiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiplyByPowerOfTen(int n)
Returns a
Decimal whose value is (this * 10n)
. |
MutableDecimal<S> |
multiplyByPowerOfTen(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * 10n)
. |
MutableDecimal<S> |
multiplyByPowerOfTen(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * 10n)
. |
MutableDecimal<?> |
multiplyExact(Decimal<?> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
MutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand)
Returns a
Decimal whose value is
(this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
MutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
int scale)
Returns a
Decimal whose value is
(this * unscaledMultiplicand × 10-scale). |
MutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is
(this * unscaledMultiplicand × 10-scale). |
MutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is
(this * unscaledMultiplicand × 10-scale). |
MutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is
(this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
MutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is
(this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
MutableDecimal<S> |
negate()
Returns a
Decimal whose value is (-this). |
MutableDecimal<S> |
negate(OverflowMode overflowMode)
Returns a
Decimal whose value is (-this). |
MutableDecimal<S> |
pow(int n)
Returns a
Decimal whose value is (thisn)
using default HALF_UP rounding. |
MutableDecimal<S> |
pow(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (thisn)
applying the specified roundingMode. |
MutableDecimal<S> |
pow(int n,
TruncationPolicy truncationPolicy)
|
MutableDecimal<S> |
remainder(Decimal<S> divisor)
Returns a
Decimal whose value is (this % divisor). |
MutableDecimal<S> |
round(int precision)
|
MutableDecimal<S> |
round(int precision,
RoundingMode roundingMode)
Returns a
Decimal value rounded to the specified
precision using the given rounding mode. |
MutableDecimal<S> |
round(int precision,
TruncationPolicy truncationPolicy)
Returns a
Decimal value rounded to the specified
precision using the given truncation policy. |
MutableDecimal<?> |
scale(int scale)
|
MutableDecimal<?> |
scale(int scale,
RoundingMode roundingMode)
|
<S extends ScaleMetrics> |
scale(S scaleMetrics)
|
<S extends ScaleMetrics> |
scale(S scaleMetrics,
RoundingMode roundingMode)
|
MutableDecimal<S> |
set(BigDecimal value)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(BigDecimal value,
RoundingMode roundingMode)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(BigInteger value)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(Decimal<?> value,
RoundingMode roundingMode)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(Decimal<S> value)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(double value)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(double value,
RoundingMode roundingMode)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(float value)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(float value,
RoundingMode roundingMode)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(long value)
Sets
this Decimal to the specified value and returns
this now representing value. |
MutableDecimal<S> |
set(String value)
Parses the given string value and sets
this Decimal to the parsed
value. |
MutableDecimal<S> |
set(String value,
RoundingMode roundingMode)
Parses the given string value and sets
this Decimal to the parsed
value. |
MutableDecimal<S> |
setMinusOne()
Sets
this Decimal to -1 and returns this now representing
minus one. |
MutableDecimal<S> |
setOne()
Sets
this Decimal to 1 and returns this now representing
one. |
MutableDecimal<S> |
setUlp()
Sets
this Decimal to the smallest positive value representable by
this Mutable Decimal and returns this now representing one ULP. |
MutableDecimal<S> |
setUnscaled(long unscaledValue)
Sets
this Decimal to the specified unscaledValue and
returns this now representing (unscaledValue * 10
-scale) where scale refers to the scale of this mutable Decimal. |
MutableDecimal<S> |
setUnscaled(long unscaledValue,
int scale)
Sets
this Decimal to the specified unscaledValue with the
given scale and returns this now representing
(unscaledValue * 10-scale). |
MutableDecimal<S> |
setUnscaled(long unscaledValue,
int scale,
RoundingMode roundingMode)
Sets
this Decimal to the specified unscaledValue with the
given scale and returns this now representing
(unscaledValue * 10-scale). |
MutableDecimal<S> |
setZero()
Sets
this Decimal to 0 and returns this now representing
zero. |
MutableDecimal<S> |
shiftLeft(int n)
Returns a
Decimal whose value is (this << n). |
MutableDecimal<S> |
shiftLeft(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this << n). |
MutableDecimal<S> |
shiftLeft(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this << n). |
MutableDecimal<S> |
shiftRight(int n)
Returns a BigInteger whose value is
(this >> n). |
MutableDecimal<S> |
shiftRight(int n,
RoundingMode roundingMode)
Returns a BigInteger whose value is
(this >> n). |
MutableDecimal<S> |
shiftRight(int n,
TruncationPolicy truncationPolicy)
Returns a BigInteger whose value is
(this >> n). |
MutableDecimal<S> |
sqrt()
Returns a
Decimal whose value is the square root of this
Decimal value. |
MutableDecimal<S> |
sqrt(RoundingMode roundingMode)
Returns a
Decimal whose value is the square root of this
Decimal value. |
MutableDecimal<S> |
square()
Returns a
Decimal whose value is (this2). |
MutableDecimal<S> |
square(RoundingMode roundingMode)
Returns a
Decimal whose value is (this2). |
MutableDecimal<S> |
square(TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this2). |
MutableDecimal<S> |
subtract(Decimal<?> subtrahend,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this - subtrahend)
after converting the given subtrahend argument to the scale of
this Decimal. |
MutableDecimal<S> |
subtract(Decimal<?> subtrahend,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this - subtrahend)
after converting the given subtrahend argument to the scale of
this Decimal. |
MutableDecimal<S> |
subtract(Decimal<S> subtrahend)
Returns a
Decimal whose value is (this - subtrahend). |
MutableDecimal<S> |
subtract(Decimal<S> subtrahend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this - subtrahend). |
MutableDecimal<S> |
subtract(double subtrahend)
Returns a
Decimal whose value is (this - subtrahend)
after converting the given double argument into a Decimal value
of the same scale as this Decimal. |
MutableDecimal<S> |
subtract(double subtrahend,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this - subtrahend)
after converting the given double argument into a Decimal value
of the same scale as this Decimal. |
MutableDecimal<S> |
subtract(long subtrahend)
Returns a
Decimal whose value is (this - subtrahend). |
MutableDecimal<S> |
subtract(long subtrahend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this - subtrahend). |
MutableDecimal<S> |
subtractSquared(Decimal<S> value)
Returns a
Decimal whose value is
(this - value2). |
MutableDecimal<S> |
subtractSquared(Decimal<S> value,
RoundingMode roundingMode)
Returns a
Decimal whose value is
(this - value2). |
MutableDecimal<S> |
subtractSquared(Decimal<S> value,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is
(this - value2). |
MutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend)
Returns a
Decimal whose value is
(this - unscaledSubtrahend × 10-scale) with the
scale of this Decimal. |
MutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend,
int scale)
Returns a
Decimal whose value is
(this - unscaledSubtrahend × 10-scale). |
MutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is
(this - unscaledSubtrahend × 10-scale). |
MutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is
(this - unscaledSubtrahend × 10-scale). |
MutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend,
OverflowMode overflowMode)
Returns a
Decimal whose value is
(this - unscaledSubtrahend × 10-scale) with the
scale of this Decimal. |
byteValue, byteValueExact, compareTo, compareToNumerically, divideToLongValue, divideToLongValue, doubleValue, doubleValue, equals, floatValue, floatValue, getFactory, getScale, getScaleMetrics, hashCode, intValue, intValueExact, isBetweenZeroAndMinusOne, isBetweenZeroAndOne, isEqualTo, isEqualToNumerically, isGreaterThan, isGreaterThanOrEqualTo, isIntegral, isIntegralPartZero, isLessThan, isLessThanOrEqualTo, isMinusOne, isNegative, isNonNegative, isNonPositive, isOne, isPositive, isUlp, isZero, longValue, longValue, longValueExact, max, min, shortValue, shortValueExact, signum, toBigDecimal, toBigDecimal, toBigInteger, toBigInteger, toBigIntegerExact, toImmutableDecimal, toMutableDecimal, toString, unscaledValueMutableDecimal<S> setZero()
this Decimal to 0 and returns this now representing
zero.this Decimal after assigning the value 0MutableDecimal<S> setOne()
this Decimal to 1 and returns this now representing
one.this Decimal after assigning the value 1MutableDecimal<S> setMinusOne()
this Decimal to -1 and returns this now representing
minus one.this Decimal after assigning the value -1MutableDecimal<S> setUlp()
this Decimal to the smallest positive value representable by
this Mutable Decimal and returns this now representing one ULP.this Decimal after assigning the value
ULP=10-scaleMutableDecimal<S> set(Decimal<S> value)
this Decimal to the specified value and returns
this now representing value.value - value to be setthis Decimal after assigning the given valueMutableDecimal<S> set(Decimal<?> value, RoundingMode roundingMode)
this Decimal to the specified value and returns
this now representing value. The specified
Decimal argument is rounded to the scale of
this mutable Decimal using RoundingMode.HALF_UP rounding. An
exception is thrown if the specified value is too large to be represented
as a Decimal of this mutable Decimal's scale.value - value to be setroundingMode - the rounding mode to apply during the conversion if necessarythis Decimal after assigning:
roundHALF_UP(value)IllegalArgumentException - if value is too large to be represented as a Decimal
with the scale of this mutable DecimalArithmeticException - if roundingMode is UNNESSESSARY and rounding is necessaryMutableDecimal<S> set(long value)
this Decimal to the specified value and returns
this now representing value. An exception is thrown if
the specified value is too large to be represented as a Decimal of this
mutable Decimal's scale.value - value to be setthis Decimal after assigning the given valueIllegalArgumentException - if value is too large to be represented as a Decimal
with the scale of this mutable DecimalMutableDecimal<S> set(BigInteger value)
this Decimal to the specified value and returns
this now representing value. An exception is thrown if
the specified value is too large to be represented as a Decimal of this
mutable Decimal's scale.value - value to be setthis Decimal after assigning the given valueIllegalArgumentException - if value is too large to be represented as a Decimal
with the scale of this mutable DecimalMutableDecimal<S> set(float value)
this Decimal to the specified value and returns
this now representing value. The specified float
argument is rounded to the scale of this mutable
Decimal using RoundingMode.HALF_UP rounding. An exception is
thrown if the specified value is too large to be represented as a Decimal
of this mutable Decimal's scale.value - value to be setthis Decimal after assigning:
roundHALF_UP(value)IllegalArgumentException - if value is NaN or infinite or if the magnitude is
too large for the float to be represented as a Decimal with
the scale of this mutable DecimalMutableDecimal<S> set(float value, RoundingMode roundingMode)
this Decimal to the specified value and returns
this now representing value. The specified float
argument is rounded to the scale of this mutable
Decimal using the specified roundingMode. An exception is thrown
if the specified value is too large to be represented as a Decimal of
this mutable Decimal's scale.value - value to be setroundingMode - the rounding mode to apply during the conversion if necessarythis Decimal after assigning: round(value)IllegalArgumentException - if value is NaN or infinite or if the magnitude is
too large for the float to be represented as a Decimal with
the scale of this mutable DecimalArithmeticException - if roundingMode is UNNESSESSARY and rounding is necessaryMutableDecimal<S> set(double value)
this Decimal to the specified value and returns
this now representing value. The specified double
argument is rounded to the scale of this mutable
Decimal using RoundingMode.HALF_UP rounding. An exception is
thrown if the specified value is too large to be represented as a Decimal
of this mutable Decimal's scale.value - value to be setthis Decimal after assigning:
roundHALF_UP(value)IllegalArgumentException - if value is NaN or infinite or if the magnitude is
too large for the double to be represented as a Decimal with
the scale of this mutable DecimalMutableDecimal<S> set(double value, RoundingMode roundingMode)
this Decimal to the specified value and returns
this now representing value. The specified double
argument is rounded to the scale of this mutable
Decimal using the specified roundingMode. An exception is thrown
if the specified value is too large to be represented as a Decimal of
this mutable Decimal's scale.value - value to be setroundingMode - the rounding mode to apply during the conversion if necessarythis Decimal after assigning: round(value)IllegalArgumentException - if value is NaN or infinite or if the magnitude is
too large for the double to be represented as a Decimal with
the scale of this mutable DecimalArithmeticException - if roundingMode is UNNESSESSARY and rounding is necessaryMutableDecimal<S> set(BigDecimal value)
this Decimal to the specified value and returns
this now representing value. The specified
BigDecimal argument is rounded to the scale
of this mutable Decimal using RoundingMode.HALF_UP rounding. An
exception is thrown if the specified value is too large to be represented
as a Decimal of this mutable Decimal's scale.value - value to be setthis Decimal after assigning:
roundHALF_UP(value)IllegalArgumentException - if value is too large to be represented as a Decimal
with the scale of this mutable DecimalMutableDecimal<S> set(BigDecimal value, RoundingMode roundingMode)
this Decimal to the specified value and returns
this now representing value. The specified
BigDecimal argument is rounded to the scale
of this mutable Decimal using the specified roundingMode. An
exception is thrown if the specified value is too large to be represented
as a Decimal of this mutable Decimal's scale.value - value to be setroundingMode - the rounding mode to apply if rounding is necessarythis Decimal after assigning: round(value)IllegalArgumentException - if value is too large to be represented as a Decimal
with the scale of this mutable DecimalArithmeticException - if roundingMode is UNNESSESSARY and rounding is necessaryMutableDecimal<S> setUnscaled(long unscaledValue)
this Decimal to the specified unscaledValue and
returns this now representing (unscaledValue * 10
-scale) where scale refers to the scale of this mutable Decimal.unscaledValue - value to be setthis Decimal after assigning:
unscaledValue * 10-scale.MutableDecimal<S> setUnscaled(long unscaledValue, int scale)
this Decimal to the specified unscaledValue with the
given scale and returns this now representing
(unscaledValue * 10-scale). The value is rounded to
the scale of this mutable Decimal using
HALF_UP rounding. An exception is thrown if
the specified value is too large to be represented as a Decimal of this
of this mutable Decimal's scale.unscaledValue - value to be setscale - the scale used for unscaledValuethis Decimal after assigning:
roundHALF_UP(unscaledValue * 10-scale)IllegalArgumentException - if the value is too large to be represented as a Decimal with
the scale of this mutable DecimalMutableDecimal<S> setUnscaled(long unscaledValue, int scale, RoundingMode roundingMode)
this Decimal to the specified unscaledValue with the
given scale and returns this now representing
(unscaledValue * 10-scale). The value is rounded to
the scale of this mutable Decimal using the specified
roundingMode. An exception is thrown if the specified value is
too large to be represented as a Decimal of this of this mutable
Decimal's scale.unscaledValue - value to be setscale - the scale used for unscaledValueroundingMode - the rounding mode to apply during the conversion if necessarythis Decimal after assigning:
round(unscaledValue * 10-scale)IllegalArgumentException - if the value is too large to be represented as a Decimal with
the scale of this mutable DecimalArithmeticException - if roundingMode is UNNESSESSARY and rounding is necessaryMutableDecimal<S> set(String value)
this Decimal to the parsed
value.
The string representation of a Decimal consists of an optional
sign, '+' or '-' , followed by a sequence of zero or more
decimal digits ("the integer"), optionally followed by a fraction.
The fraction consists of a decimal point followed by zero or more decimal
digits. The string must contain at least one digit in either the integer
or the fraction. If the fraction contains more digits than this mutable
Decimal's scale, the value is rounded using
HALF_UP rounding. An exception is thrown if
the value is too large to be represented as a Decimal of this mutable
Decimals's scale.
value - the string value to parse and assignthis Decimal after assigning the parsed valueNumberFormatException - if value does not represent a valid Decimal
or if the value is too large to be represented as a Decimal
with the scale of this mutable Decimal's scaleMutableDecimal<S> set(String value, RoundingMode roundingMode)
this Decimal to the parsed
value.
The string representation of a Decimal consists of an optional
sign, '+' or '-' , followed by a sequence of zero or more
decimal digits ("the integer"), optionally followed by a fraction.
The fraction consists of a decimal point followed by zero or more decimal
digits. The string must contain at least one digit in either the integer
or the fraction. If the fraction contains more digits than this mutable
Decimal's scale, the value is rounded using the
specified roundingMode. An exception is thrown if the value is
too large to be represented as a Decimal of this mutable Decimals's
scale.
value - the string value to parse and assignroundingMode - the rounding mode to apply if the fraction contains more
digits than the scale of this mutable Decimalthis Decimal after assigning the parsed valueNumberFormatException - if value does not represent a valid Decimal
or if the value is too large to be represented as a Decimal
with the scale of this mutable Decimal's scaleArithmeticException - if roundingMode==UNNECESSARY and rounding is
necessaryMutableDecimal<S> min(MutableDecimal<S> val)
Decimal and val.val - value with which the minimum is to be computed.Decimal whose value is the lesser of this
Decimal and val. If they are equal, as defined by
the compareTo method, this is
returned.Decimal.compareTo(Decimal)MutableDecimal<S> max(MutableDecimal<S> val)
Decimal and val.val - value with which the maximum is to be computed.Decimal whose value is the greater of this
Decimal and val. If they are equal, as defined by
the compareTo method, this is
returned.Decimal.compareTo(Decimal)MutableDecimal<S> clone()
MutableDecimal<S> integralPart()
DecimalDecimal whose value represents the integral part of
this Decimal. The integral part corresponds to digits at the left
of the decimal point. The result is this Decimal rounded to
precision zero with RoundingMode.DOWN.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the operation.
integralPart in interface Decimal<S extends ScaleMetrics>⌊this⌋ for non-negative and
⌈this⌉ for negative valuesDecimal.fractionalPart(),
Decimal.isIntegral(),
Decimal.isIntegralPartZero(),
Decimal.round(int, RoundingMode)MutableDecimal<S> fractionalPart()
DecimalDecimal whose value represents the fractional part of
(this) value. The fractional part corresponds to digits at the
right of the decimal point. The result is this minus the integral
part of this Decimal.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the operation.
fractionalPart in interface Decimal<S extends ScaleMetrics>this-integralPart() which is always less than one and
greater than minus oneDecimal.integralPart(),
Decimal.isIntegral(),
Decimal.isIntegralPartZero()MutableDecimal<S> round(int precision)
DecimalDecimal value rounded to the specified
precision using HALF_UP rounding. If
an overflow occurs due to the rounding operation, the result is silently
truncated.
Note that contrary to the scale(..) operations this method does
not change the scale of the value --- extra digits are simply zeroised.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the rounded value.
Examples and special cases:
IllegalArgumentException is thrownround in interface Decimal<S extends ScaleMetrics>precision - the precision to use for the rounding, for instance 2 to round
to the second digit after the decimal point; must be at least
(scale - 18)Decimal.round(int, RoundingMode),
Decimal.round(int, TruncationPolicy),
Decimal.scale(int)MutableDecimal<S> round(int precision, RoundingMode roundingMode)
DecimalDecimal value rounded to the specified
precision using the given rounding mode. If an overflow occurs
due to the rounding operation, the result is silently truncated.
Note that contrary to the scale(..) operations this method does
not change the scale of the value --- extra digits are simply zeroised.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the rounded value.
Examples and special cases:
IllegalArgumentException is thrownround in interface Decimal<S extends ScaleMetrics>precision - the precision to use for the rounding, for instance 2 to round
to the second digit after the decimal point; must be at least
(scale - 18)roundingMode - the rounding mode to apply when rounding to the desired
precisionDecimal.round(int),
Decimal.round(int, TruncationPolicy),
Decimal.scale(int, RoundingMode)MutableDecimal<S> round(int precision, TruncationPolicy truncationPolicy)
DecimalDecimal value rounded to the specified
precision using the given truncation policy.
Note that contrary to the scale(..) operations this method does
not change the scale of the value --- extra digits are simply zeroised.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the rounded value.
Examples and special cases:
IllegalArgumentException is thrownround in interface Decimal<S extends ScaleMetrics>precision - the precision to use for the rounding, for instance 2 to round
to the second digit after the decimal point; must be at least
(scale - 18)truncationPolicy - the truncation policy defining RoundingMode and
OverflowMode for the rounding operationDecimal.round(int),
Decimal.round(int, RoundingMode),
Decimal.scale(int, RoundingMode)MutableDecimal<?> scale(int scale)
DecimalDecimal value whose scale is
changed to the given scale value. HALF_UP rounding is used if the scale change involves rounding.
An exception is thrown if the scale conversion leads to an overflow.
scale in interface Decimal<S extends ScaleMetrics>scale - the scale to use for the result, must be in [0,18]Decimal.scale(ScaleMetrics),
Decimal.scale(int, RoundingMode),
Decimal.round(int)<S extends ScaleMetrics> MutableDecimal<S> scale(S scaleMetrics)
DecimalDecimal value whose scale is
changed to the scale given by the scaleMetrics argument.
HALF_UP rounding is used if the scale change
involves rounding.
An exception is thrown if the scale conversion leads to an overflow.
scale in interface Decimal<S extends ScaleMetrics>S - the scale metrics type of the resultscaleMetrics - the scale metrics to use for the resultDecimal.scale(int),
Decimal.scale(ScaleMetrics, RoundingMode),
Decimal.round(int)MutableDecimal<?> scale(int scale, RoundingMode roundingMode)
DecimalDecimal value whose scale is
changed to the given scale value. The specified
roundingMode is used if the scale change involves rounding.
An exception is thrown if the scale conversion leads to an overflow.
scale in interface Decimal<S extends ScaleMetrics>scale - the scale to use for the result, must be in [0,18]roundingMode - the rounding mode to apply if the scale change involves
roundingDecimal.scale(int),
Decimal.scale(ScaleMetrics, RoundingMode),
Decimal.round(int, RoundingMode)<S extends ScaleMetrics> MutableDecimal<S> scale(S scaleMetrics, RoundingMode roundingMode)
DecimalDecimal value whose scale is
changed to the scale given by the scaleMetrics argument. The
specified roundingMode is used if the scale change involves
rounding.
An exception is thrown if the scale conversion leads to an overflow.
scale in interface Decimal<S extends ScaleMetrics>S - the scale metrics type of the resultscaleMetrics - the scale metrics to use for the resultroundingMode - the rounding mode to apply if the scale change involves
roundingDecimal.scale(ScaleMetrics),
Decimal.scale(int, RoundingMode),
Decimal.round(int, RoundingMode)MutableDecimal<S> add(Decimal<S> augend)
DecimalDecimal whose value is (this + augend). If the
addition causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
add in interface Decimal<S extends ScaleMetrics>augend - value to be added to this Decimalthis + augendMutableDecimal<S> add(Decimal<S> augend, OverflowMode overflowMode)
DecimalDecimal whose value is (this + augend). The
specified overflowMode determines whether to truncate the result
silently or to throw an exception if an overflow occurs.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
add in interface Decimal<S extends ScaleMetrics>augend - value to be added to this DecimaloverflowMode - the overflow mode to apply if the addition leads to an
overflowthis + augendMutableDecimal<S> add(Decimal<?> augend, RoundingMode roundingMode)
DecimalDecimal whose value is (this + augend). The
result of the addition is rounded if necessary using the specified
roundingMode. Overflows during scale conversion or subtraction
are silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
add in interface Decimal<S extends ScaleMetrics>augend - value to be added to this DecimalroundingMode - the rounding mode to apply if rounding is necessaryMutableDecimal<S> add(Decimal<?> augend, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this + augend). The
result of the addition is rounded if necessary using the
RoundingMode defined by the truncationPolicy argument.
The truncationPolicy also defines the OverflowMode to
apply if the operation causes an overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
add in interface Decimal<S extends ScaleMetrics>augend - value to be added to this DecimaltruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occurs during the additionround(this + augend)MutableDecimal<S> add(long augend)
DecimalDecimal whose value is (this + augend) after
converting the given long value to the scale of this
Decimal. If the operation causes an overflow, the result is silently
truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
add in interface Decimal<S extends ScaleMetrics>augend - long value to be added to this Decimalthis + augendMutableDecimal<S> add(long augend, OverflowMode overflowMode)
DecimalDecimal whose value is (this + augend) after
converting the given long value to the scale of this
Decimal. The specified overflowMode determines whether to
truncate the result silently or to throw an exception if an overflow
occurs.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
add in interface Decimal<S extends ScaleMetrics>augend - long value to be added to this DecimaloverflowMode - the overflow mode to apply if the addition leads to an
overflowthis + augendMutableDecimal<S> add(double augend)
DecimalDecimal whose value is (this + augend) after
converting the given double argument into a Decimal value of the
same scale as this Decimal. If rounding is necessary,
HALF_UP rounding mode is used and applied
during the conversion step before the addition operation.
Overflows due to conversion or addition result in an exception.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
add in interface Decimal<S extends ScaleMetrics>augend - value to be added to this DecimalMutableDecimal<S> add(double augend, RoundingMode roundingMode)
DecimalDecimal whose value is (this + augend) after
converting the given double argument into a Decimal value of the
same scale as this Decimal. If rounding is necessary, the
specified roundingMode is used and applied during the conversion
step before the addition operation. Overflows due to conversion or
addition result in an exception.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
add in interface Decimal<S extends ScaleMetrics>augend - value to be added to this DecimalroundingMode - the rounding mode to apply if the augend argument needs to be
rounded when converted into a Decimal number of the same scale
as this Decimalthis + round(augend)MutableDecimal<S> addUnscaled(long unscaledAugend)
DecimalDecimal whose value is
(this + unscaledAugend × 10-scale) with the
scale of this Decimal. If the addition causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
addUnscaled in interface Decimal<S extends ScaleMetrics>unscaledAugend - value to be added to this DecimalMutableDecimal<S> addUnscaled(long unscaledAugend, OverflowMode overflowMode)
DecimalDecimal whose value is
(this + unscaledAugend × 10-scale) with the
scale of this Decimal. The specified
overflowMode determines whether to truncate the result silently
or to throw an exception if an overflow occurs.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
addUnscaled in interface Decimal<S extends ScaleMetrics>unscaledAugend - value to be added to this DecimaloverflowMode - the overflow mode to apply if the addition leads to an
overflowMutableDecimal<S> addUnscaled(long unscaledAugend, int scale)
DecimalDecimal whose value is
(this + unscaledAugend × 10-scale). The result
of the addition is rounded if necessary using HALF_UP rounding. If the operation causes an overflow, the result is
silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
addUnscaled in interface Decimal<S extends ScaleMetrics>unscaledAugend - value to be added to this Decimalscale - the scale to apply to unscaledAugend, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tenMutableDecimal<S> addUnscaled(long unscaledAugend, int scale, RoundingMode roundingMode)
DecimalDecimal whose value is
(this + unscaledAugend × 10-scale). The result
of the addition is rounded if necessary using the specified
roundingMode. If the operation causes an overflow, the result is
silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
addUnscaled in interface Decimal<S extends ScaleMetrics>unscaledAugend - value to be added to this Decimalscale - the scale to apply to unscaledAugend, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tenroundingMode - the rounding mode to apply if rounding is necessaryMutableDecimal<S> addUnscaled(long unscaledAugend, int scale, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is
(this + unscaledAugend × 10-scale). The result
of the addition is rounded if necessary using the RoundingMode
defined by the truncationPolicy argument. The
truncationPolicy also defines the OverflowMode to apply
if the operation causes an overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
addUnscaled in interface Decimal<S extends ScaleMetrics>unscaledAugend - value to be added to this Decimalscale - the scale to apply to unscaledAugend, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tentruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occurs during the additionMutableDecimal<S> addSquared(Decimal<S> value)
DecimalDecimal whose value is
(this + value2). The squared value is rounded
before the addition if necessary using default
HALF_UP rounding. Overflows during squaring
or addition are silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
addSquared in interface Decimal<S extends ScaleMetrics>value - value to be squared and added to this DecimalMutableDecimal<S> addSquared(Decimal<S> value, RoundingMode roundingMode)
DecimalDecimal whose value is
(this + value2). The squared value is rounded
before the addition if necessary using the specified
roundingMode. Overflows during squaring or addition are silently
truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
addSquared in interface Decimal<S extends ScaleMetrics>value - value to be squared and added to this DecimalroundingMode - the rounding mode to apply if necessary when squaring the
valueMutableDecimal<S> addSquared(Decimal<S> value, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is
(this + value2). The squared value is rounded
before the addition if necessary using the RoundingMode
specified by the truncationPolicy argument. The
truncationPolicy also defines the OverflowMode to apply
if an overflow occurs during square or add operation.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the addition.
addSquared in interface Decimal<S extends ScaleMetrics>value - value to be squared and added to this DecimaltruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary when
squaring the value or if an overflow occurs during the square
or add operationMutableDecimal<S> subtract(Decimal<S> subtrahend)
DecimalDecimal whose value is (this - subtrahend). If
the subtraction causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtract in interface Decimal<S extends ScaleMetrics>subtrahend - value to be subtracted from this Decimalthis - subtrahendMutableDecimal<S> subtract(Decimal<S> subtrahend, OverflowMode overflowMode)
DecimalDecimal whose value is (this - subtrahend). The
specified overflowMode determines whether to truncate the result
silently or to throw an exception if an overflow occurs.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtract in interface Decimal<S extends ScaleMetrics>subtrahend - value to be subtracted from this DecimaloverflowMode - the overflow mode to apply if the subtraction leads to an
overflowthis - subtrahendMutableDecimal<S> subtract(Decimal<?> subtrahend, RoundingMode roundingMode)
DecimalDecimal whose value is (this - subtrahend)
after converting the given subtrahend argument to the scale of
this Decimal. The result of the subtraction is rounded if
necessary using the specified roundingMode. Overflows during
scale conversion or subtraction are silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtract in interface Decimal<S extends ScaleMetrics>subtrahend - value to be subtracted from this DecimalroundingMode - the rounding mode to apply if rounding is necessaryMutableDecimal<S> subtract(Decimal<?> subtrahend, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this - subtrahend)
after converting the given subtrahend argument to the scale of
this Decimal. The result of the subtraction is rounded if
necessary using the RoundingMode defined by the
truncationPolicy argument. The truncationPolicy also
defines the OverflowMode to apply if the operation causes an
overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtract in interface Decimal<S extends ScaleMetrics>subtrahend - value to be subtracted from this DecimaltruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occurs during the subtractionMutableDecimal<S> subtract(long subtrahend)
DecimalDecimal whose value is (this - subtrahend). If
the subtraction causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtract in interface Decimal<S extends ScaleMetrics>subtrahend - long value to be subtracted from this Decimalthis - subtrahendMutableDecimal<S> subtract(long subtrahend, OverflowMode overflowMode)
DecimalDecimal whose value is (this - subtrahend). The
specified overflowMode determines whether to truncate the result
silently or to throw an exception if an overflow occurs.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtract in interface Decimal<S extends ScaleMetrics>subtrahend - long value to be subtracted from this DecimaloverflowMode - the overflow mode to apply if the subtraction leads to an
overflowthis - subtrahendMutableDecimal<S> subtract(double subtrahend)
DecimalDecimal whose value is (this - subtrahend)
after converting the given double argument into a Decimal value
of the same scale as this Decimal. If rounding is necessary,
HALF_UP rounding mode is used and applied
during the conversion step before the subtraction operation.
Overflows due to conversion or subtraction result in an exception.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtract in interface Decimal<S extends ScaleMetrics>subtrahend - value to be subtracted from this DecimalMutableDecimal<S> subtract(double subtrahend, RoundingMode roundingMode)
DecimalDecimal whose value is (this - subtrahend)
after converting the given double argument into a Decimal value
of the same scale as this Decimal. If rounding is necessary, the
specified roundingMode is used and applied during the conversion
step before the subtraction operation. Overflows due to conversion
or subtraction result in an exception.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtract in interface Decimal<S extends ScaleMetrics>subtrahend - value to be subtracted from this DecimalroundingMode - the rounding mode to apply if the subtrahend argument needs to
be rounded when converted into a Decimal number of the same
scale as this DecimalMutableDecimal<S> subtractUnscaled(long unscaledSubtrahend)
DecimalDecimal whose value is
(this - unscaledSubtrahend × 10-scale) with the
scale of this Decimal. If the subtraction causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtractUnscaled in interface Decimal<S extends ScaleMetrics>unscaledSubtrahend - value to be subtracted from this DecimalMutableDecimal<S> subtractUnscaled(long unscaledSubtrahend, OverflowMode overflowMode)
DecimalDecimal whose value is
(this - unscaledSubtrahend × 10-scale) with the
scale of this Decimal. The specified
overflowMode determines whether to truncate the result silently
or to throw an exception if an overflow occurs.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtractUnscaled in interface Decimal<S extends ScaleMetrics>unscaledSubtrahend - value to be subtracted from this DecimaloverflowMode - the overflow mode to apply if the subtraction leads to an
overflowMutableDecimal<S> subtractUnscaled(long unscaledSubtrahend, int scale)
DecimalDecimal whose value is
(this - unscaledSubtrahend × 10-scale). The
result of the subtraction is rounded if necessary using
HALF_UP rounding. If the operation causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtractUnscaled in interface Decimal<S extends ScaleMetrics>unscaledSubtrahend - value to be subtracted from this Decimalscale - the scale to apply to unscaledSubtrahend, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tenMutableDecimal<S> subtractUnscaled(long unscaledSubtrahend, int scale, RoundingMode roundingMode)
DecimalDecimal whose value is
(this - unscaledSubtrahend × 10-scale). The
result of the subtraction is rounded if necessary using the specified
roundingMode. If the operation causes an overflow, the result is
silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtractUnscaled in interface Decimal<S extends ScaleMetrics>unscaledSubtrahend - value to be subtracted from this Decimalscale - the scale to apply to unscaledSubtrahend, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tenroundingMode - the rounding mode to apply if rounding is necessaryMutableDecimal<S> subtractUnscaled(long unscaledSubtrahend, int scale, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is
(this - unscaledSubtrahend × 10-scale). The
result of the subtraction is rounded if necessary using the
RoundingMode defined by the truncationPolicy argument.
The truncationPolicy also defines the OverflowMode to
apply if the operation causes an overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtractUnscaled in interface Decimal<S extends ScaleMetrics>unscaledSubtrahend - value to be subtracted from this Decimalscale - the scale to apply to unscaledSubtrahend, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tentruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occurs during the subtractionMutableDecimal<S> subtractSquared(Decimal<S> value)
DecimalDecimal whose value is
(this - value2). The squared value is rounded
before the subtraction if necessary using default
HALF_UP rounding. Overflows during squaring
or subtraction are silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtractSquared in interface Decimal<S extends ScaleMetrics>value - value to be squared and subtracted from this DecimalMutableDecimal<S> subtractSquared(Decimal<S> value, RoundingMode roundingMode)
DecimalDecimal whose value is
(this - value2). The squared value is rounded
before the subtraction if necessary using the specified
roundingMode. Overflows during squaring or subtraction are
silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtractSquared in interface Decimal<S extends ScaleMetrics>value - value to be squared and subtracted from this DecimalroundingMode - the rounding mode to apply if necessary when squaring the
valueMutableDecimal<S> subtractSquared(Decimal<S> value, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is
(this - value2). The squared value is rounded
before the subtraction if necessary using the RoundingMode
specified by the truncationPolicy argument. The
truncationPolicy also defines the OverflowMode to apply
if an overflow occurs during square or subtract operation.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the subtraction.
subtractSquared in interface Decimal<S extends ScaleMetrics>value - value to be squared and subtracted from this DecimaltruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary when
squaring the value or if an overflow occurs during the square
or subtract operationMutableDecimal<S> multiply(Decimal<S> multiplicand)
DecimalDecimal whose value is (this * multiplicand).
The result is rounded to the scale of this Decimal
using default HALF_UP rounding. If the
multiplication causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiply in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimalMutableDecimal<S> multiply(Decimal<S> multiplicand, RoundingMode roundingMode)
DecimalDecimal whose value is (this * multiplicand).
The result is rounded to the scale of this Decimal
using the specified roundingMode. If the multiplication causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiply in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimalroundingMode - the rounding mode to apply if the result needs to be roundedMutableDecimal<S> multiply(Decimal<S> multiplicand, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this * multiplicand).
The result is rounded to the scale of this Decimal
using the RoundingMode specified by the truncationPolicy
argument. The truncationPolicy also defines the
OverflowMode to apply if an overflow occurs during the multiply
operation.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiply in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimaltruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<S> multiplyBy(Decimal<?> multiplicand)
DecimalDecimal whose value is (this * multiplicand).
The result is rounded to the scale of this Decimal
using HALF_UP rounding. If the
multiplication causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyBy in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimalMutableDecimal<S> multiplyBy(Decimal<?> multiplicand, RoundingMode roundingMode)
DecimalDecimal whose value is (this * multiplicand).
The result is rounded to the scale of this Decimal
using the specified roundingMode. If the multiplication causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyBy in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimalroundingMode - the rounding mode to apply if rounding is necessaryMutableDecimal<S> multiplyBy(Decimal<?> multiplicand, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this * multiplicand).
The result is rounded to the scale of this Decimal
using the RoundingMode defined by the truncationPolicy
argument. The truncationPolicy also defines the
OverflowMode to apply if the operation causes an overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyBy in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimaltruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<?> multiplyExact(Decimal<?> multiplicand)
DecimalDecimal whose value is (this * multiplicand).
The scale of the returned value is the sum of the scales of this
Decimal and the multiplicand argument. If the result scale
exceeds 18, an IllegalArgumentException is thrown. An
ArithmeticException is thrown if the product is out of the
possible range for a Decimal with the result scale.
Note that the result is always a new instance --- immutable if
this Decimal is an ImmutableDecimal and mutable if it is a
MutableDecimal.
multiplyExact in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this Decimal(this * multiplicand) with scale equal to the sum of
scales of this and multiplicandMutableDecimal<S> multiply(long multiplicand)
DecimalDecimal whose value is (this * multiplicand).
If the multiplication causes an overflow, the result is silently
truncated.
This method performs multiplication of this Decimal with a
long value which is usually more efficient than multiplication of
two Decimal values.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiply in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this Decimal(this * multiplicand)MutableDecimal<S> multiply(long multiplicand, OverflowMode overflowMode)
DecimalDecimal whose value is (this * multiplicand).
The specified overflowMode determines whether to truncate the
result silently or to throw an exception if an overflow occurs.
This method performs multiplication of this Decimal with a
long value which is usually more efficient than multiplication of
two Decimal values.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiply in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimaloverflowMode - the overflow mode to apply if the multiplication leads to an
overflow(this * multiplicand)MutableDecimal<S> multiply(double multiplicand)
DecimalDecimal whose value is (this * multiplicand)
after converting the given double argument into a Decimal value
of the same scale as this Decimal. HALF_UP rounding mode is used if necessary and applied twice during the
conversion step before the multiplication and again when rounding
the product to the scale of this Decimal. Overflows
due to conversion or multiplication result in an exception.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiply in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimalMutableDecimal<S> multiply(double multiplicand, RoundingMode roundingMode)
DecimalDecimal whose value is (this * multiplicand)
after converting the given double argument into a Decimal value
of the same scale as this Decimal. Rounding, if necessary, uses
the specified roundingMode and is applied during the conversion
step before the multiplication and again when rounding the product
to the scale of this Decimal. Overflows due to
conversion or multiplication result in an exception.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiply in interface Decimal<S extends ScaleMetrics>multiplicand - factor to multiply with this DecimalroundingMode - the rounding mode to apply if the converted multiplicand or
the resulting product needs to be roundedround(this * round(multiplicand))MutableDecimal<S> multiplyUnscaled(long unscaledMultiplicand)
DecimalDecimal whose value is
(this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. The result is rounded to
the scale of this Decimal using default HALF_UP rounding. If the multiplication causes an overflow, the result
is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyUnscaled in interface Decimal<S extends ScaleMetrics>unscaledMultiplicand - factor to multiply with this DecimalMutableDecimal<S> multiplyUnscaled(long unscaledMultiplicand, RoundingMode roundingMode)
DecimalDecimal whose value is
(this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. The result is rounded to
the scale of this Decimal using the specified roundingMode. If
the multiplication causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyUnscaled in interface Decimal<S extends ScaleMetrics>unscaledMultiplicand - factor to multiply with this DecimalroundingMode - the rounding mode to apply if the result needs to be roundedMutableDecimal<S> multiplyUnscaled(long unscaledMultiplicand, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is
(this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. The result is rounded to
the scale of this Decimal using the using the RoundingMode
specified by the truncationPolicy argument. The
truncationPolicy also defines the OverflowMode to apply
if an overflow occurs during the multiplication.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyUnscaled in interface Decimal<S extends ScaleMetrics>unscaledMultiplicand - factor to multiply with this DecimaltruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<S> multiplyUnscaled(long unscaledMultiplicand, int scale)
DecimalDecimal whose value is
(this * unscaledMultiplicand × 10-scale). The
result of the multiplication is rounded to the scale
of this Decimal using HALF_UP rounding. If
the operation causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyUnscaled in interface Decimal<S extends ScaleMetrics>unscaledMultiplicand - factor to multiply with this Decimalscale - the scale to apply to unscaledMultiplicand, positive
to indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tenMutableDecimal<S> multiplyUnscaled(long unscaledMultiplicand, int scale, RoundingMode roundingMode)
DecimalDecimal whose value is
(this * unscaledMultiplicand × 10-scale). The
result of the multiplication is rounded to the scale
of this Decimal using the specified roundingMode. If the
operation causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyUnscaled in interface Decimal<S extends ScaleMetrics>unscaledMultiplicand - factor to multiply with this Decimalscale - the scale to apply to unscaledMultiplicand, positive
to indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tenroundingMode - the rounding mode to apply if rounding is necessaryMutableDecimal<S> multiplyUnscaled(long unscaledMultiplicand, int scale, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is
(this * unscaledMultiplicand × 10-scale). The
result of the multiplication is rounded to the scale
of this Decimal using the RoundingMode defined by the
truncationPolicy argument. The truncationPolicy also
defines the OverflowMode to apply if the operation causes an
overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyUnscaled in interface Decimal<S extends ScaleMetrics>unscaledMultiplicand - factor to multiply with this Decimalscale - the scale to apply to unscaledMultiplicand, positive
to indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tentruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<S> multiplyByPowerOfTen(int n)
DecimalDecimal whose value is (this * 10n)
. For negative n the multiplication turns into a de-facto
division and the result is rounded to the scale of
this Decimal using default HALF_UP rounding.
If the multiplication causes an overflow, the result is silently
truncated.
The result of this operation is the same as for
divideByPowerOfTen(-n) given
n > Integer.MIN_VALUE.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyByPowerOfTen in interface Decimal<S extends ScaleMetrics>n - the exponent of the power-of-ten factor to multiply with this
DecimalMutableDecimal<S> multiplyByPowerOfTen(int n, RoundingMode roundingMode)
DecimalDecimal whose value is (this * 10n)
. For negative n the multiplication turns into a de-facto
division and the result is rounded to the scale of
this Decimal using the specified roundingMode. If the
multiplication causes an overflow, the result is silently truncated.
The result of this operation is the same as for
divideByPowerOfTen(-n,
roundingMode) given n > Integer.MIN_VALUE.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyByPowerOfTen in interface Decimal<S extends ScaleMetrics>n - the exponent of the power-of-ten factor to multiply with this
DecimalroundingMode - the rounding mode to apply if the result needs to be rounded
for the case n < 0MutableDecimal<S> multiplyByPowerOfTen(int n, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this * 10n)
. For negative n the multiplication turns into a de-facto
division and the result is rounded to the scale of
this Decimal using the RoundingMode specified by the
truncationPolicy argument. The truncationPolicy also
defines the OverflowMode to apply if an overflow occurs during
the multiplication.
The result of this operation is the same as for
divideByPowerOfTen(-n,
truncationPolicy) given n > Integer.MIN_VALUE.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the multiplication.
multiplyByPowerOfTen in interface Decimal<S extends ScaleMetrics>n - the exponent of the power-of-ten factor to multiply with this
DecimaltruncationPolicy - the truncation policy specifying RoundingMode to apply
if rounding is necessary when n < 0 as well
OverflowMode to use if n > 0 and an overflow
occurs during the multiplicationMutableDecimal<S> divide(Decimal<S> divisor)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
HALF_UP rounding. If the division causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divide in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedMutableDecimal<S> divide(Decimal<S> divisor, RoundingMode roundingMode)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
the specified roundingMode. If the division causes an overflow,
the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divide in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedroundingMode - the rounding mode to apply if the result needs to be roundedround(this / divisor)MutableDecimal<S> divide(Decimal<S> divisor, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
the RoundingMode specified by the truncationPolicy
argument. The truncationPolicy also defines the
OverflowMode to apply if an overflow occurs during the divide
operation.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divide in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedtruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<S> divideBy(Decimal<?> divisor)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
HALF_UP rounding. If the division causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideBy in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedMutableDecimal<S> divideBy(Decimal<?> divisor, RoundingMode roundingMode)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
the specified roundingMode. If the division causes an overflow,
the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideBy in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedroundingMode - the rounding mode to apply if rounding is necessaryround(this / divisor)MutableDecimal<S> divideBy(Decimal<?> divisor, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
the RoundingMode defined by the truncationPolicy
argument. The truncationPolicy also defines the
OverflowMode to apply if the operation causes an overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideBy in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedtruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursround(this / divisor)MutableDecimal<S> divideTruncate(Decimal<S> divisor)
DecimalDecimal whose value is (this / divisor) rounded
down. This method is a shortcut for calling
divide(divisor, RoundingMode.DOWN).
If the division causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideTruncate in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedMutableDecimal<S> divideExact(Decimal<S> divisor)
DecimalDecimal whose value is (this / divisor),
checking for lost information. If the quotient cannot be represented
exactly with the scale of this Decimal then an
ArithmeticException is thrown.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideExact in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedthis / divisorMutableDecimal<S> divide(long divisor)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
HALF_UP rounding. If the division causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divide in interface Decimal<S extends ScaleMetrics>divisor - long value by which this Decimal is to be dividedMutableDecimal<S> divide(long divisor, RoundingMode roundingMode)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
the specified roundingMode. If the division causes an overflow,
the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divide in interface Decimal<S extends ScaleMetrics>divisor - long value by which this Decimal is to be dividedroundingMode - the rounding mode to apply if the result needs to be roundedround(this / divisor)MutableDecimal<S> divide(long divisor, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this / divisor). The
result is rounded to the scale of this Decimal using
the RoundingMode specified by the truncationPolicy
argument. The truncationPolicy also defines the
OverflowMode to apply if an overflow occurs during the divide
operation.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divide in interface Decimal<S extends ScaleMetrics>divisor - long value by which this Decimal is to be dividedtruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<S> divide(double divisor)
DecimalDecimal whose value is (this / divisor) after
converting the given double argument into a Decimal value of the
same scale as this Decimal. HALF_UP
rounding mode is used if necessary and applied twice during the
conversion step before the division and again when rounding the
quotient to the scale of this Decimal. Overflows due
to conversion or division result in an exception.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divide in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedMutableDecimal<S> divide(double divisor, RoundingMode roundingMode)
DecimalDecimal whose value is (this / divisor) after
converting the given double argument into a Decimal value of the
same scale as this Decimal. Rounding, if necessary, uses the
specified roundingMode and is applied during the conversion step
before the division and again when rounding the quotient to the
scale of this Decimal. Overflows due to conversion or
division result in an exception.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divide in interface Decimal<S extends ScaleMetrics>divisor - divisor value by which this Decimal is to be dividedroundingMode - the rounding mode to apply if the converted divisor or the
resulting quotient needs to be roundedround(this / round(divisor))MutableDecimal<S> divideUnscaled(long unscaledDivisor)
DecimalDecimal whose value is
(this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. The result is rounded to the
scale of this Decimal using default HALF_UP
rounding. If the division causes an overflow, the result is silently
truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideUnscaled in interface Decimal<S extends ScaleMetrics>unscaledDivisor - divisor value by which this Decimal is to be dividedMutableDecimal<S> divideUnscaled(long unscaledDivisor, RoundingMode roundingMode)
DecimalDecimal whose value is
(this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. The result is rounded to the
scale of this Decimal using the specified roundingMode. If the
division causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideUnscaled in interface Decimal<S extends ScaleMetrics>unscaledDivisor - divisor value by which this Decimal is to be dividedroundingMode - the rounding mode to apply if the result needs to be roundedMutableDecimal<S> divideUnscaled(long unscaledDivisor, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is
(this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. The result is rounded to the
scale of this Decimal using the using the RoundingMode specified
by the truncationPolicy argument. The truncationPolicy
also defines the OverflowMode to apply if an overflow occurs
during the division.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideUnscaled in interface Decimal<S extends ScaleMetrics>unscaledDivisor - divisor value by which this Decimal is to be dividedtruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<S> divideUnscaled(long unscaledDivisor, int scale)
DecimalDecimal whose value is
(this / (unscaledDivisor × 10-scale)). The
result is rounded to the scale of this Decimal using
HALF_UP rounding. If the operation causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideUnscaled in interface Decimal<S extends ScaleMetrics>unscaledDivisor - divisor value by which this Decimal is to be dividedscale - the scale to apply to unscaledDivisor, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tenMutableDecimal<S> divideUnscaled(long unscaledDivisor, int scale, RoundingMode roundingMode)
DecimalDecimal whose value is
(this / (unscaledDivisor × 10-scale)). The
result is rounded to the scale of this Decimal using the specified
roundingMode. If the operation causes an overflow, the result is
silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideUnscaled in interface Decimal<S extends ScaleMetrics>unscaledDivisor - divisor value by which this Decimal is to be dividedscale - the scale to apply to unscaledDivisor, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tenroundingMode - the rounding mode to apply if the result needs to be roundedMutableDecimal<S> divideUnscaled(long unscaledDivisor, int scale, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is
(this / (unscaledDivisor × 10-scale)). The
result is rounded to the scale of this Decimal using the
RoundingMode defined by the truncationPolicy argument.
The truncationPolicy also defines the OverflowMode to
apply if the operation causes an overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideUnscaled in interface Decimal<S extends ScaleMetrics>unscaledDivisor - divisor value by which this Decimal is to be dividedscale - the scale to apply to unscaledDivisor, positive to
indicate the number of fraction digits to the right of the
Decimal point and negative to indicate up-scaling with a power
of tentruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<S> divideByPowerOfTen(int n)
DecimalDecimal whose value is (this / 10n)
. The result is rounded to the scale of this Decimal
using HALF_UP rounding.
For negative n the division turns into a de-facto multiplication. If the multiplication causes an overflow, the result is silently truncated.
The result of this operation is the same as for
multiplyByPowerOfTen(-n) (unless
n == Integer.MIN_VALUE).
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideByPowerOfTen in interface Decimal<S extends ScaleMetrics>n - the exponent of the power-of-ten divisor by which this
Decimal is to be dividedMutableDecimal<S> divideByPowerOfTen(int n, RoundingMode roundingMode)
DecimalDecimal whose value is (this / 10n)
. The result is rounded to the scale of this Decimal
using the specified roudningMode.
For negative n the division turns into a de-facto multiplication. If the multiplication causes an overflow, the result is silently truncated.
The result of this operation is the same as for
multiplyByPowerOfTen(-n,
roundingMode) (unless n == Integer.MIN_VALUE).
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideByPowerOfTen in interface Decimal<S extends ScaleMetrics>n - the exponent of the power-of-ten divisor by which this
Decimal is to be dividedroundingMode - the rounding mode to apply if the result needs to be rounded
for the case n > 0MutableDecimal<S> divideByPowerOfTen(int n, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this / 10n)
. The result is rounded to the scale of this Decimal
using the RoundingMode specified by the truncationPolicy
argument.
For negative n the division turns into a de-facto multiplication
and truncationPolicy defines the OverflowMode to apply if
an overflow occurs during the multiplication.
The result of this operation is the same as for
multiplyByPowerOfTen(-n, truncationPolicy) (unless n ==
Integer.MIN_VALUE).
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideByPowerOfTen in interface Decimal<S extends ScaleMetrics>n - the exponent of the power-of-ten divisor by which this
Decimal is to be dividedtruncationPolicy - the truncation policy specifying RoundingMode to apply
if rounding is necessary when n > 0 as well
OverflowMode to use if n < 0 and an overflow
occurs during the de-facto multiplicationMutableDecimal<S> divideToIntegralValue(Decimal<S> divisor)
DecimalDecimal whose value is (this / divisor) rounded
down to the next integer. If the division causes an overflow, the result
is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideToIntegralValue in interface Decimal<S extends ScaleMetrics>divisor - value by which this Decimal is to be divided.(this / divisor).Decimal.divideToIntegralValue(Decimal, OverflowMode),
Decimal.divideToLongValue(Decimal),
Decimal.remainder(Decimal)MutableDecimal<S> divideToIntegralValue(Decimal<S> divisor, OverflowMode overflowMode)
DecimalDecimal whose value is (this / divisor) rounded
down to the next integer. The specified overflowMode determines
whether to truncate the result silently or to throw an exception if an
overflow occurs.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
divideToIntegralValue in interface Decimal<S extends ScaleMetrics>divisor - value by which this Decimal is to be divided.overflowMode - the overflow mode to apply if the division leads to an
overflow(this / divisor).Decimal.divideToIntegralValue(Decimal),
Decimal.divideToLongValue(Decimal),
Decimal.remainder(Decimal)MutableDecimal<S>[] divideAndRemainder(Decimal<S> divisor)
DecimalDecimal array containing the result of
divideToIntegralValue followed by the result of remainder
on the two operands. If the division causes an overflow, the result is
silently truncated.
Note that if both the integer quotient and remainder are needed, this
method is faster than using the divideToIntegralValue and
remainder methods separately because the division need only be
carried out once.
divideAndRemainder in interface Decimal<S extends ScaleMetrics>divisor - value by which this Decimal is to be divided, and the
remainder computed.Decimal array: the quotient (the result of
divideToIntegralValue) is the initial element and the
remainder is the final element.Decimal.divideAndRemainder(Decimal, OverflowMode),
Decimal.divideToIntegralValue(Decimal),
Decimal.remainder(Decimal)MutableDecimal<S>[] divideAndRemainder(Decimal<S> divisor, OverflowMode overflowMode)
DecimalDecimal array containing the result of
divideToIntegralValue followed by the result of remainder
on the two operands. The specified overflowMode determines
whether to truncate the result silently or to throw an exception if an
overflow occurs.
Note that if both the integer quotient and remainder are needed, this
method is faster than using the divideToIntegralValue and
remainder methods separately because the division need only be
carried out once.
divideAndRemainder in interface Decimal<S extends ScaleMetrics>divisor - value by which this Decimal is to be divided, and the
remainder computed.overflowMode - the overflow mode to apply if the division leads to an
overflowDecimal array: the quotient (the result of
divideToIntegralValue) is the initial element and the
remainder is the final element.Decimal.divideAndRemainder(Decimal),
Decimal.divideToIntegralValue(Decimal),
Decimal.remainder(Decimal)MutableDecimal<S> remainder(Decimal<S> divisor)
DecimalDecimal whose value is (this % divisor).
The remainder is given by
this.subtract(this.divideToIntegralValue(divisor).multiply(divisor))
. Note that this is not the modulo operation (the result can be
negative).
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the operation.
remainder in interface Decimal<S extends ScaleMetrics>divisor - value by which this Decimal is to be divided.this % divisor.Decimal.divideToIntegralValue(Decimal),
Decimal.divideAndRemainder(Decimal)MutableDecimal<S> negate()
DecimalDecimal whose value is (-this).
If an overflow occurs (which is true iff
this.unscaledValue()==Long.MIN_VALUE) then the result is still
negative and numerically equal to this value.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
negate in interface Decimal<S extends ScaleMetrics>-thisMutableDecimal<S> negate(OverflowMode overflowMode)
DecimalDecimal whose value is (-this).
The specified overflowMode determines whether to truncate the
result silently or to throw an exception if an overflow occurs (which is
true iff this.unscaledValue()==Long.MIN_VALUE).
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
negate in interface Decimal<S extends ScaleMetrics>overflowMode - the overflow mode to apply-thisMutableDecimal<S> abs()
DecimalDecimal whose value is the absolute value of this
Decimal.
If an overflow occurs (which is true iff
this.unscaledValue()==Long.MIN_VALUE) then the result is still
negative and numerically equal to this value.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
abs in interface Decimal<S extends ScaleMetrics>abs(this)MutableDecimal<S> abs(OverflowMode overflowMode)
DecimalDecimal whose value is the absolute value of this
Decimal.
The specified overflowMode determines whether to truncate the
result silently or to throw an exception if an overflow occurs (which is
true iff this.unscaledValue()==Long.MIN_VALUE).
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the division.
abs in interface Decimal<S extends ScaleMetrics>overflowMode - the overflow mode to applyabs(this)MutableDecimal<S> invert()
DecimalDecimal whose value is (1 / this). The result
is rounded to the scale of this Decimal using default
HALF_UP rounding. If the inversion causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the inversion.
invert in interface Decimal<S extends ScaleMetrics>MutableDecimal<S> invert(RoundingMode roundingMode)
DecimalDecimal whose value is (1 / this). The result
is rounded to the scale of this Decimal using the
specified roundingMode. If the inversion causes an overflow, the
result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the inversion.
invert in interface Decimal<S extends ScaleMetrics>roundingMode - the rounding mode to apply if the result needs to be roundedround(1 / this)MutableDecimal<S> invert(TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (1 / this). The result
is rounded to the scale of this Decimal using the
RoundingMode specified by the truncationPolicy argument.
The truncationPolicy also defines the OverflowMode to
apply if an overflow occurs during the invert operation.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the inversion.
invert in interface Decimal<S extends ScaleMetrics>truncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursround(1 / this)MutableDecimal<S> square()
DecimalDecimal whose value is (this2). The
result is rounded to the scale of this Decimal using
default HALF_UP rounding. If the square
operation causes an overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the square operation.
square in interface Decimal<S extends ScaleMetrics>MutableDecimal<S> square(RoundingMode roundingMode)
DecimalDecimal whose value is (this2). The
result is rounded to the scale of this Decimal using
the specified roundingMode. If the square operation causes an
overflow, the result is silently truncated.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the square operation.
square in interface Decimal<S extends ScaleMetrics>roundingMode - the rounding mode to apply if the result needs to be roundedround(this * this)MutableDecimal<S> square(TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this2). The
result is rounded to the scale of this Decimal using
the RoundingMode specified by the truncationPolicy
argument. The truncationPolicy also defines the
OverflowMode to apply if an overflow occurs during the square
operation.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the square operation.
square in interface Decimal<S extends ScaleMetrics>truncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursround(this * this)MutableDecimal<S> sqrt()
DecimalDecimal whose value is the square root of this
Decimal value. The result is rounded to the scale of
this Decimal using default HALF_UP rounding.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the operation.
sqrt in interface Decimal<S extends ScaleMetrics>sqrt(this)MutableDecimal<S> sqrt(RoundingMode roundingMode)
DecimalDecimal whose value is the square root of this
Decimal value. The result is rounded to the scale of
this Decimal using the specified roundingMode.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the operation.
sqrt in interface Decimal<S extends ScaleMetrics>roundingMode - the rounding mode to apply if the result needs to be roundedsqrt(this)MutableDecimal<S> shiftLeft(int n)
DecimalDecimal whose value is (this << n). The shift
distance, n, may be negative, in which case this method performs
a right shift.
Computes floor(this * 2n).
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
shiftLeft in interface Decimal<S extends ScaleMetrics>n - shift distance, in bits.this << nDecimal.shiftRight(int)MutableDecimal<S> shiftLeft(int n, RoundingMode roundingMode)
DecimalDecimal whose value is (this << n). The shift
distance, n, may be negative, in which case this method performs
a right shift.
Computes round(this * 2n) using the specified
roundingMode.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
shiftLeft in interface Decimal<S extends ScaleMetrics>n - shift distance, in bits.roundingMode - the rounding mode to use if truncation is involved for
negative n, that is, for right shiftsthis << nDecimal.shiftRight(int)MutableDecimal<S> shiftLeft(int n, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (this << n). The shift
distance, n, may be negative, in which case this method performs
a right shift.
Computes round(this * 2n) using the
RoundingMode specified by the truncationPolicy argument.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
shiftLeft in interface Decimal<S extends ScaleMetrics>n - shift distance, in bits.truncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursthis << nDecimal.shiftRight(int)MutableDecimal<S> shiftRight(int n)
Decimal(this >> n). Sign extension
is performed. The shift distance, n, may be negative, in which
case this method performs a left shift.
Computes floor(this / 2n).
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
shiftRight in interface Decimal<S extends ScaleMetrics>n - shift distance, in bits.this >> nDecimal.shiftLeft(int)MutableDecimal<S> shiftRight(int n, RoundingMode roundingMode)
Decimal(this >> n). Sign extension
is performed. The shift distance, n, may be negative, in which
case this method performs a left shift.
Computes round(this / 2n) using the specified
roundingMode.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
shiftRight in interface Decimal<S extends ScaleMetrics>n - shift distance, in bits.roundingMode - the rounding mode to use if truncation is involvedthis >> nDecimal.shiftLeft(int)MutableDecimal<S> shiftRight(int n, TruncationPolicy truncationPolicy)
Decimal(this >> n). Sign extension
is performed. The shift distance, n, may be negative, in which
case this method performs a left shift.
Computes round(this / 2n) using the
RoundingMode specified by the truncationPolicy argument.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
shiftRight in interface Decimal<S extends ScaleMetrics>n - shift distance, in bits.truncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursthis >> nDecimal.shiftLeft(int)MutableDecimal<S> pow(int n)
DecimalDecimal whose value is (thisn)
using default HALF_UP rounding.
The current implementation uses the core algorithm defined in ANSI
standard X3.274-1996. For n >= 0, the returned numerical value is
within 1 ULP of the exact numerical value. No precision is guaranteed for
n < 0 but the result is usually exact up to 10-20 ULP.
Properties of the X3.274-1996 algorithm are:
IllegalArgumentException is thrown if
abs(n) > 999999999n is zero, one is returned even if this is zero,
otherwise
n is positive, the result is calculated via the repeated
squaring technique into a single accumulatorn is negative, the result is calculated as if n
were positive; this value is then divided into oneHALF_UP rounding
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
pow in interface Decimal<S extends ScaleMetrics>n - power to raise this Decimal toMutableDecimal<S> pow(int n, RoundingMode roundingMode)
DecimalDecimal whose value is (thisn)
applying the specified roundingMode.
The current implementation uses the core algorithm defined in ANSI
standard X3.274-1996. For n >= 0, the returned numerical value is
within 1 ULP of the exact numerical value; the result is actually exact
for all rounding modes other than HALF_UP, HALF_EVEN and HALF_DOWN. No
precision is guaranteed for n < 0 but the result is usually exact
up to 10-20 ULP.
Properties of the X3.274-1996 algorithm are:
IllegalArgumentException is thrown if
abs(n) > 999999999n is zero, one is returned even if this is zero,
otherwise
n is positive, the result is calculated via the repeated
squaring technique into a single accumulatorn is negative, the result is calculated as if n
were positive; this value is then divided into oneroundingMode
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
pow in interface Decimal<S extends ScaleMetrics>n - power to raise this Decimal toroundingMode - the rounding mode to apply if rounding is necessaryMutableDecimal<S> pow(int n, TruncationPolicy truncationPolicy)
DecimalDecimal whose value is (thisn)
applying the RoundingMode specified by truncationPolicy.
The truncationPolicy argument also defines the
OverflowMode to apply if an overflow occurs during the power
operation.
The current implementation uses the core algorithm defined in ANSI
standard X3.274-1996. For n >= 0, the returned numerical value is
within 1 ULP of the exact numerical value; the result is actually exact
for all rounding modes other than HALF_UP, HALF_EVEN and HALF_DOWN. No
precision is guaranteed for n < 0 but the result is usually exact
up to 10-20 ULP.
Properties of the X3.274-1996 algorithm are:
IllegalArgumentException is thrown if
abs(n) > 999999999n is zero, one is returned even if this is zero,
otherwise
n is positive, the result is calculated via the repeated
squaring technique into a single accumulatorn is negative, the result is calculated as if n
were positive; this value is then divided into oneRoundingMode specified by
truncationPolicy
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the shift operation.
pow in interface Decimal<S extends ScaleMetrics>n - power to raise this Decimal totruncationPolicy - the truncation policy specifying RoundingMode and
OverflowMode to apply if rounding is necessary or if
an overflow occursMutableDecimal<S> avg(Decimal<S> val)
DecimalDecimal and val. The result
is rounded to the scale of this Decimal using default
HALF_UP rounding. The method is much more
efficient than an addition and subsequent long division and is guaranteed
not to overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the average operation.
avg in interface Decimal<S extends ScaleMetrics>val - value with which the average is to be computed.MutableDecimal<S> avg(Decimal<S> val, RoundingMode roundingMode)
DecimalDecimal and val. The result
is rounded to the scale of this Decimal using the
specified roundingMode. The method is much more efficient than an
addition and subsequent long division and is guaranteed not to overflow.
The returned value is a new instance if this Decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing the outcome of the average operation.
avg in interface Decimal<S extends ScaleMetrics>val - value with which the average is to be computed.roundingMode - the rounding mode to use if rounding is necessaryround((this + val) / 2)