S - the scale metrics type associated with this Decimalpublic interface ImmutableDecimal<S extends ScaleMetrics> extends Decimal<S>
Decimal classes of different
scales. Immutable Decimals allocate a new Decimals instance for results of
arithmetic operations.
Consider also MutableDecimal descendants especially for chained
operations.
Immutable Decimals are thread safe.
| Modifier and Type | Method and Description |
|---|---|
ImmutableDecimal<S> |
abs()
Returns a
Decimal whose value is the absolute value of this Decimal. |
ImmutableDecimal<S> |
abs(OverflowMode overflowMode)
Returns a
Decimal whose value is the absolute value of this Decimal. |
ImmutableDecimal<S> |
add(Decimal<?> augend,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this + augend). |
ImmutableDecimal<S> |
add(Decimal<?> augend,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this + augend). |
ImmutableDecimal<S> |
add(Decimal<S> augend)
Returns a
Decimal whose value is (this + augend). |
ImmutableDecimal<S> |
add(Decimal<S> augend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this + augend). |
ImmutableDecimal<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. |
ImmutableDecimal<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. |
ImmutableDecimal<S> |
add(long augend)
Returns a
Decimal whose value is (this + augend) after converting the given long value to
the scale of this Decimal. |
ImmutableDecimal<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. |
ImmutableDecimal<S> |
addSquared(Decimal<S> value)
Returns a
Decimal whose value is (this + value2). |
ImmutableDecimal<S> |
addSquared(Decimal<S> value,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this + value2). |
ImmutableDecimal<S> |
addSquared(Decimal<S> value,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this + value2). |
ImmutableDecimal<S> |
addUnscaled(long unscaledAugend)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale) with the
scale of this Decimal. |
ImmutableDecimal<S> |
addUnscaled(long unscaledAugend,
int scale)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale). |
ImmutableDecimal<S> |
addUnscaled(long unscaledAugend,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale). |
ImmutableDecimal<S> |
addUnscaled(long unscaledAugend,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale). |
ImmutableDecimal<S> |
addUnscaled(long unscaledAugend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale) with the
scale of this Decimal. |
ImmutableDecimal<S> |
avg(Decimal<S> val)
Returns the average of this
Decimal and val. |
ImmutableDecimal<S> |
avg(Decimal<S> val,
RoundingMode roundingMode)
Returns the average of this
Decimal and val. |
ImmutableDecimal<S> |
divide(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<S> |
divide(Decimal<S> divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<S> |
divide(Decimal<S> divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<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. |
ImmutableDecimal<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. |
ImmutableDecimal<S> |
divide(long divisor)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<S> |
divide(long divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<S> |
divide(long divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<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. |
ImmutableDecimal<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. |
ImmutableDecimal<S> |
divideBy(Decimal<?> divisor)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<S> |
divideBy(Decimal<?> divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<S> |
divideBy(Decimal<?> divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
ImmutableDecimal<S> |
divideByPowerOfTen(int n)
Returns a
Decimal whose value is (this / 10n) . |
ImmutableDecimal<S> |
divideByPowerOfTen(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / 10n) . |
ImmutableDecimal<S> |
divideByPowerOfTen(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / 10n) . |
ImmutableDecimal<S> |
divideExact(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor), checking for lost information. |
ImmutableDecimal<S> |
divideToIntegralValue(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor) rounded down to the next integer. |
ImmutableDecimal<S> |
divideToIntegralValue(Decimal<S> divisor,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this / divisor) rounded down to the next integer. |
ImmutableDecimal<S> |
divideTruncate(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor) rounded down. |
ImmutableDecimal<S> |
divideUnscaled(long unscaledDivisor)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
ImmutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
int scale)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)). |
ImmutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)). |
ImmutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)). |
ImmutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
ImmutableDecimal<S> |
divideUnscaled(long unscaledDivisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
ImmutableDecimal<S> |
fractionalPart()
Returns a
Decimal whose value represents the fractional part of (this) value. |
ImmutableDecimal<S> |
integralPart()
Returns a
Decimal whose value represents the integral part of this Decimal. |
ImmutableDecimal<S> |
invert()
Returns a
Decimal whose value is (1 / this). |
ImmutableDecimal<S> |
invert(RoundingMode roundingMode)
Returns a
Decimal whose value is (1 / this). |
ImmutableDecimal<S> |
invert(TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (1 / this). |
ImmutableDecimal<S> |
max(ImmutableDecimal<S> val)
Returns the maximum of this
Decimal and val. |
ImmutableDecimal<S> |
min(ImmutableDecimal<S> val)
Returns the minimum of this
Decimal and val. |
ImmutableDecimal<S> |
multiply(Decimal<S> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<S> |
multiply(Decimal<S> multiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<S> |
multiply(Decimal<S> multiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<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. |
ImmutableDecimal<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. |
ImmutableDecimal<S> |
multiply(long multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<S> |
multiply(long multiplicand,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<S> |
multiplyBy(Decimal<?> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<S> |
multiplyBy(Decimal<?> multiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<S> |
multiplyBy(Decimal<?> multiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<S> |
multiplyByPowerOfTen(int n)
Returns a
Decimal whose value is (this * 10n) . |
ImmutableDecimal<S> |
multiplyByPowerOfTen(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * 10n) . |
ImmutableDecimal<S> |
multiplyByPowerOfTen(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * 10n) . |
ImmutableDecimal<?> |
multiplyExact(Decimal<?> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
ImmutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
int scale)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale). |
ImmutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale). |
ImmutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale). |
ImmutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
ImmutableDecimal<S> |
multiplyUnscaled(long unscaledMultiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
ImmutableDecimal<S> |
negate()
Returns a
Decimal whose value is (-this). |
ImmutableDecimal<S> |
negate(OverflowMode overflowMode)
Returns a
Decimal whose value is (-this). |
ImmutableDecimal<S> |
pow(int n)
Returns a
Decimal whose value is (thisn) using default HALF_UP rounding. |
ImmutableDecimal<S> |
pow(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (thisn) applying the specified roundingMode. |
ImmutableDecimal<S> |
pow(int n,
TruncationPolicy truncationPolicy)
|
ImmutableDecimal<S> |
remainder(Decimal<S> divisor)
Returns a
Decimal whose value is (this % divisor). |
ImmutableDecimal<S> |
round(int precision)
|
ImmutableDecimal<S> |
round(int precision,
RoundingMode roundingMode)
Returns a
Decimal value rounded to the specified precision using the given rounding mode. |
ImmutableDecimal<S> |
round(int precision,
TruncationPolicy truncationPolicy)
Returns a
Decimal value rounded to the specified precision using the given truncation policy. |
ImmutableDecimal<?> |
scale(int scale)
|
ImmutableDecimal<?> |
scale(int scale,
RoundingMode roundingMode)
|
<S extends ScaleMetrics> |
scale(S scaleMetrics)
|
<S extends ScaleMetrics> |
scale(S scaleMetrics,
RoundingMode roundingMode)
|
ImmutableDecimal<S> |
shiftLeft(int n)
Returns a
Decimal whose value is (this << n). |
ImmutableDecimal<S> |
shiftLeft(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this << n). |
ImmutableDecimal<S> |
shiftLeft(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this << n). |
ImmutableDecimal<S> |
shiftRight(int n)
Returns a BigInteger whose value is
(this >> n). |
ImmutableDecimal<S> |
shiftRight(int n,
RoundingMode roundingMode)
Returns a BigInteger whose value is
(this >> n). |
ImmutableDecimal<S> |
shiftRight(int n,
TruncationPolicy truncationPolicy)
Returns a BigInteger whose value is
(this >> n). |
ImmutableDecimal<S> |
sqrt()
Returns a
Decimal whose value is the square root of this Decimal value. |
ImmutableDecimal<S> |
sqrt(RoundingMode roundingMode)
Returns a
Decimal whose value is the square root of this Decimal value. |
ImmutableDecimal<S> |
square()
Returns a
Decimal whose value is (this2). |
ImmutableDecimal<S> |
square(RoundingMode roundingMode)
Returns a
Decimal whose value is (this2). |
ImmutableDecimal<S> |
square(TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this2). |
ImmutableDecimal<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. |
ImmutableDecimal<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. |
ImmutableDecimal<S> |
subtract(Decimal<S> subtrahend)
Returns a
Decimal whose value is (this - subtrahend). |
ImmutableDecimal<S> |
subtract(Decimal<S> subtrahend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this - subtrahend). |
ImmutableDecimal<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. |
ImmutableDecimal<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. |
ImmutableDecimal<S> |
subtract(long subtrahend)
Returns a
Decimal whose value is (this - subtrahend). |
ImmutableDecimal<S> |
subtract(long subtrahend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this - subtrahend). |
ImmutableDecimal<S> |
subtractSquared(Decimal<S> value)
Returns a
Decimal whose value is (this - value2). |
ImmutableDecimal<S> |
subtractSquared(Decimal<S> value,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this - value2). |
ImmutableDecimal<S> |
subtractSquared(Decimal<S> value,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this - value2). |
ImmutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale) with
the scale of this Decimal. |
ImmutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend,
int scale)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale). |
ImmutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale). |
ImmutableDecimal<S> |
subtractUnscaled(long unscaledSubtrahend,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale). |
ImmutableDecimal<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, unscaledValueImmutableDecimal<S> min(ImmutableDecimal<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)ImmutableDecimal<S> max(ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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()ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<?> 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> ImmutableDecimal<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)ImmutableDecimal<?> 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> ImmutableDecimal<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)ImmutableDecimal<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 + augendImmutableDecimal<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 + augendImmutableDecimal<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 necessaryImmutableDecimal<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)ImmutableDecimal<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 + augendImmutableDecimal<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 + augendImmutableDecimal<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 DecimalImmutableDecimal<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)ImmutableDecimal<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 DecimalImmutableDecimal<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 overflowImmutableDecimal<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 tenImmutableDecimal<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 necessaryImmutableDecimal<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 additionImmutableDecimal<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 DecimalImmutableDecimal<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 valueImmutableDecimal<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 operationImmutableDecimal<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 - subtrahendImmutableDecimal<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 - subtrahendImmutableDecimal<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 necessaryImmutableDecimal<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 subtractionImmutableDecimal<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 - subtrahendImmutableDecimal<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 - subtrahendImmutableDecimal<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 DecimalImmutableDecimal<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 DecimalImmutableDecimal<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 DecimalImmutableDecimal<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 overflowImmutableDecimal<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 tenImmutableDecimal<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 necessaryImmutableDecimal<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 subtractionImmutableDecimal<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 DecimalImmutableDecimal<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 valueImmutableDecimal<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 operationImmutableDecimal<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 DecimalImmutableDecimal<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 roundedImmutableDecimal<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 occursImmutableDecimal<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 DecimalImmutableDecimal<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 necessaryImmutableDecimal<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 occursImmutableDecimal<?> 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
multiplicandImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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 DecimalImmutableDecimal<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))ImmutableDecimal<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 DecimalImmutableDecimal<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 roundedImmutableDecimal<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 occursImmutableDecimal<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 tenImmutableDecimal<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 necessaryImmutableDecimal<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 occursImmutableDecimal<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 DecimalImmutableDecimal<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 < 0ImmutableDecimal<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
multiplicationImmutableDecimal<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 dividedImmutableDecimal<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)ImmutableDecimal<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 occursImmutableDecimal<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 dividedImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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 dividedImmutableDecimal<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 / divisorImmutableDecimal<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 dividedImmutableDecimal<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)ImmutableDecimal<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 occursImmutableDecimal<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 dividedImmutableDecimal<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))ImmutableDecimal<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 dividedImmutableDecimal<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 roundedImmutableDecimal<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 occursImmutableDecimal<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 tenImmutableDecimal<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 roundedImmutableDecimal<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 occursImmutableDecimal<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 dividedImmutableDecimal<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 > 0ImmutableDecimal<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 multiplicationImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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>-thisImmutableDecimal<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-thisImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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>ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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>ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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)ImmutableDecimal<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 toImmutableDecimal<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 necessaryImmutableDecimal<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 occursImmutableDecimal<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.ImmutableDecimal<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)