S - the scale metrics type associated with this decimalD - the concrete class implementing this decimalpublic abstract class AbstractDecimal<S extends ScaleMetrics,D extends AbstractDecimal<S,D>> extends Number implements Decimal<S>
| Constructor and Description |
|---|
AbstractDecimal() |
| Modifier and Type | Method and Description |
|---|---|
D |
abs()
Returns a
Decimal whose value is the absolute value of this Decimal. |
D |
abs(OverflowMode overflowMode)
Returns a
Decimal whose value is the absolute value of this Decimal. |
D |
add(Decimal<?> augend,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this + augend). |
D |
add(Decimal<?> augend,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this + augend). |
D |
add(Decimal<S> augend)
Returns a
Decimal whose value is (this + augend). |
D |
add(Decimal<S> augend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this + augend). |
D |
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. |
D |
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. |
D |
add(long augend)
Returns a
Decimal whose value is (this + augend) after converting the given long value to
the scale of this Decimal. |
D |
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. |
D |
addSquared(Decimal<S> value)
Returns a
Decimal whose value is (this + value2). |
D |
addSquared(Decimal<S> value,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this + value2). |
D |
addSquared(Decimal<S> value,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this + value2). |
D |
addUnscaled(long unscaledAugend)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale) with the
scale of this Decimal. |
D |
addUnscaled(long unscaledAugend,
int scale)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale). |
D |
addUnscaled(long unscaledAugend,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale). |
D |
addUnscaled(long unscaledAugend,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale). |
D |
addUnscaled(long unscaledAugend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this + unscaledAugend × 10-scale) with the
scale of this Decimal. |
D |
avg(Decimal<S> val)
Returns the average of this
Decimal and val. |
D |
avg(Decimal<S> val,
RoundingMode roundingMode)
Returns the average of this
Decimal and val. |
byte |
byteValueExact()
Converts this
Decimal to a byte, checking for lost information. |
int |
compareTo(Decimal<S> other)
Compares two
Decimal objects numerically. |
int |
compareToNumerically(Decimal<?> other)
Compares this
Decimal with the specified Decimal. |
protected abstract D |
create(long unscaled)
Returns a new
Decimal whose value is
(unscaled × 10-scale). |
protected abstract D[] |
createArray(int length)
Returns a new
Decimal array of the specified length. |
protected abstract D |
createOrAssign(long unscaled)
Returns this or a new
Decimal whose value is
(unscaled × 10-scale). |
D |
divide(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor). |
D |
divide(Decimal<S> divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
D |
divide(Decimal<S> divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
D |
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. |
D |
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. |
D |
divide(long divisor)
Returns a
Decimal whose value is (this / divisor). |
D |
divide(long divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
D |
divide(long divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
D[] |
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. |
D[] |
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. |
D |
divideBy(Decimal<?> divisor)
Returns a
Decimal whose value is (this / divisor). |
D |
divideBy(Decimal<?> divisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / divisor). |
D |
divideBy(Decimal<?> divisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / divisor). |
D |
divideByPowerOfTen(int n)
Returns a
Decimal whose value is (this / 10n) . |
D |
divideByPowerOfTen(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / 10n) . |
D |
divideByPowerOfTen(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / 10n) . |
D |
divideExact(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor), checking for lost information. |
D |
divideToIntegralValue(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor) rounded down to the next integer. |
D |
divideToIntegralValue(Decimal<S> divisor,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this / divisor) rounded down to the next integer. |
long |
divideToLongValue(Decimal<S> divisor)
Returns a
Decimal whose value (this / divisor) rounded down to the next long value. |
long |
divideToLongValue(Decimal<S> divisor,
OverflowMode overflowMode)
Returns a
Decimal whose value (this / divisor) rounded down to the next long value. |
D |
divideTruncate(Decimal<S> divisor)
Returns a
Decimal whose value is (this / divisor) rounded down. |
D |
divideUnscaled(long unscaledDivisor)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
D |
divideUnscaled(long unscaledDivisor,
int scale)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)). |
D |
divideUnscaled(long unscaledDivisor,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)). |
D |
divideUnscaled(long unscaledDivisor,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)). |
D |
divideUnscaled(long unscaledDivisor,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
D |
divideUnscaled(long unscaledDivisor,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this / (unscaledDivisor × 10-scale)) with the
scale of this Decimal. |
double |
doubleValue()
Converts this
Decimal to a double. |
double |
doubleValue(RoundingMode roundingMode)
Converts this
Decimal to a double using the specified rounding mode if the Decimal value can not
be exactly represented as a double value. |
boolean |
equals(Object obj)
Compares this Decimal to the specified object.
|
float |
floatValue()
Converts this
Decimal to a float. |
float |
floatValue(RoundingMode roundingMode)
Converts this
Decimal to a float using the specified rounding mode if the Decimal value can not
be exactly represented as a float value. |
D |
fractionalPart()
Returns a
Decimal whose value represents the fractional part of (this) value. |
protected DecimalArithmetic |
getArithmeticFor(OverflowMode overflowMode)
Returns the default arithmetic performing checked operations with
rounding mode
HALF_UP and the specified
overflowMode. |
protected DecimalArithmetic |
getArithmeticFor(RoundingMode roundingMode)
Returns the arithmetic performing unchecked operations with the specified
RoundingMode. |
protected DecimalArithmetic |
getArithmeticFor(TruncationPolicy truncationPolicy)
Returns the arithmetic for the specified
truncationPolicy. |
protected DecimalArithmetic |
getCheckedArithmeticFor(RoundingMode roundingMode)
Returns the arithmetic performing checked operations with the specified
RoundingMode. |
protected DecimalArithmetic |
getDefaultArithmetic()
Returns the default arithmetic performing unchecked operations with
rounding mode
HALF_UP. |
protected DecimalArithmetic |
getDefaultCheckedArithmetic()
Returns the default arithmetic performing checked operations with
rounding mode
HALF_UP. |
protected DecimalArithmetic |
getRoundingDownArithmetic()
Returns the arithmetic performing unchecked operations with rounding mode
DOWN. |
protected DecimalArithmetic |
getRoundingFloorArithmetic()
Returns the arithmetic performing unchecked operations with rounding mode
FLOOR. |
protected DecimalArithmetic |
getRoundingHalfEvenArithmetic()
Returns the arithmetic performing unchecked operations with rounding mode
HALF_EVEN. |
protected DecimalArithmetic |
getRoundingUnnecessaryArithmetic()
Returns the arithmetic performing unchecked operations with rounding mode
UNNECESSARY. |
int |
hashCode()
Returns a hash code for this
Decimal. |
D |
integralPart()
Returns a
Decimal whose value represents the integral part of this Decimal. |
int |
intValue()
Converts this
Decimal to an int. |
int |
intValueExact()
Converts this
Decimal to an int, checking for lost information. |
D |
invert()
Returns a
Decimal whose value is (1 / this). |
D |
invert(RoundingMode roundingMode)
Returns a
Decimal whose value is (1 / this). |
D |
invert(TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (1 / this). |
boolean |
isBetweenZeroAndMinusOne()
Returns true if this
Decimal is between zero (inclusive) and minus one (exclusive). |
boolean |
isBetweenZeroAndOne()
Returns true if this
Decimal is between zero (inclusive) and one (exclusive). |
boolean |
isEqualTo(Decimal<S> other)
Compares this
Decimal with the specified Decimal and returns true if the two are numerically
equal. |
boolean |
isEqualToNumerically(Decimal<?> other)
Compares this
Decimal with the specified Decimal and returns true if the two are numerically
equal. |
boolean |
isGreaterThan(Decimal<S> other)
Compares this
Decimal with the specified Decimal and returns true if this Decimal is numerically
greater than other. |
boolean |
isGreaterThanOrEqualTo(Decimal<S> other)
Compares this
Decimal with the specified Decimal and returns true if this Decimal is numerically
greater than or equal to other. |
boolean |
isIntegral()
Returns true if this
Decimal number is integral, or equivalently if its fractional part is zero. |
boolean |
isIntegralPartZero()
Returns true if the
integral part of this Decimal number is zero. |
boolean |
isLessThan(Decimal<S> other)
Compares this
Decimal with the specified Decimal and returns true if this Decimal is numerically
less than other. |
boolean |
isLessThanOrEqualTo(Decimal<S> other)
Compares this
Decimal with the specified Decimal and returns true if this Decimal is numerically
less than or equal to other. |
boolean |
isMinusOne()
Returns true if this
Decimal is minus one. |
boolean |
isNegative()
Returns true if this
Decimal is negative. |
boolean |
isNonNegative()
Returns true if this
Decimal is not negative. |
boolean |
isNonPositive()
Returns true if this
Decimal is not positive. |
boolean |
isOne()
Returns true if this
Decimal is one. |
boolean |
isPositive()
Returns true if this
Decimal is strictly positive. |
boolean |
isUlp()
Returns true if this
Decimal is equal to the smallest positive number representable by a Decimal with the
current scale. |
boolean |
isZero()
Returns true if this
Decimal is zero. |
long |
longValue()
Converts this
Decimal to a long. |
long |
longValue(RoundingMode roundingMode)
Converts this
Decimal to a long using the specified rounding mode if necessary. |
long |
longValueExact()
Converts this
Decimal to a long, checking for lost information. |
D |
max(D val)
Returns the maximum of this
Decimal and val. |
Decimal<S> |
max(Decimal<S> val)
Returns the maximum of this
Decimal and val. |
D |
min(D val)
Returns the minimum of this
Decimal and val. |
Decimal<S> |
min(Decimal<S> val)
Returns the minimum of this
Decimal and val. |
D |
multiply(Decimal<S> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
D |
multiply(Decimal<S> multiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * multiplicand). |
D |
multiply(Decimal<S> multiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * multiplicand). |
D |
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. |
D |
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. |
D |
multiply(long multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
D |
multiply(long multiplicand,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this * multiplicand). |
D |
multiplyBy(Decimal<?> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
D |
multiplyBy(Decimal<?> multiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * multiplicand). |
D |
multiplyBy(Decimal<?> multiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * multiplicand). |
D |
multiplyByPowerOfTen(int n)
Returns a
Decimal whose value is (this * 10n) . |
D |
multiplyByPowerOfTen(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * 10n) . |
D |
multiplyByPowerOfTen(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * 10n) . |
D |
multiplyUnscaled(long unscaledMultiplicand)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
D |
multiplyUnscaled(long unscaledMultiplicand,
int scale)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale). |
D |
multiplyUnscaled(long unscaledMultiplicand,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale). |
D |
multiplyUnscaled(long unscaledMultiplicand,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale). |
D |
multiplyUnscaled(long unscaledMultiplicand,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
D |
multiplyUnscaled(long unscaledMultiplicand,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this * unscaledMultiplicand × 10-scale) with
the scale of this Decimal. |
D |
negate()
Returns a
Decimal whose value is (-this). |
D |
negate(OverflowMode overflowMode)
Returns a
Decimal whose value is (-this). |
D |
pow(int n)
Returns a
Decimal whose value is (thisn) using default HALF_UP rounding. |
D |
pow(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (thisn) applying the specified roundingMode. |
D |
pow(int n,
TruncationPolicy truncationPolicy)
|
D |
remainder(Decimal<S> divisor)
Returns a
Decimal whose value is (this % divisor). |
D |
round(int precision)
|
D |
round(int precision,
RoundingMode roundingMode)
Returns a
Decimal value rounded to the specified precision using the given rounding mode. |
D |
round(int precision,
TruncationPolicy truncationPolicy)
Returns a
Decimal value rounded to the specified precision using the given truncation policy. |
protected abstract D |
self()
Returns
this decimal value as concrete implementation subtype. |
D |
shiftLeft(int n)
Returns a
Decimal whose value is (this << n). |
D |
shiftLeft(int n,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this << n). |
D |
shiftLeft(int n,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this << n). |
D |
shiftRight(int n)
Returns a BigInteger whose value is
(this >> n). |
D |
shiftRight(int n,
RoundingMode roundingMode)
Returns a BigInteger whose value is
(this >> n). |
D |
shiftRight(int n,
TruncationPolicy truncationPolicy)
Returns a BigInteger whose value is
(this >> n). |
short |
shortValueExact()
Converts this
Decimal to a short, checking for lost information. |
int |
signum()
Returns the signum function of this
Decimal. |
D |
sqrt()
Returns a
Decimal whose value is the square root of this Decimal value. |
D |
sqrt(RoundingMode roundingMode)
Returns a
Decimal whose value is the square root of this Decimal value. |
D |
square()
Returns a
Decimal whose value is (this2). |
D |
square(RoundingMode roundingMode)
Returns a
Decimal whose value is (this2). |
D |
square(TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this2). |
D |
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. |
D |
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. |
D |
subtract(Decimal<S> subtrahend)
Returns a
Decimal whose value is (this - subtrahend). |
D |
subtract(Decimal<S> subtrahend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this - subtrahend). |
D |
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. |
D |
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. |
D |
subtract(long subtrahend)
Returns a
Decimal whose value is (this - subtrahend). |
D |
subtract(long subtrahend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this - subtrahend). |
D |
subtractSquared(Decimal<S> value)
Returns a
Decimal whose value is (this - value2). |
D |
subtractSquared(Decimal<S> value,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this - value2). |
D |
subtractSquared(Decimal<S> value,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this - value2). |
D |
subtractUnscaled(long unscaledSubtrahend)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale) with
the scale of this Decimal. |
D |
subtractUnscaled(long unscaledSubtrahend,
int scale)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale). |
D |
subtractUnscaled(long unscaledSubtrahend,
int scale,
RoundingMode roundingMode)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale). |
D |
subtractUnscaled(long unscaledSubtrahend,
int scale,
TruncationPolicy truncationPolicy)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale). |
D |
subtractUnscaled(long unscaledSubtrahend,
OverflowMode overflowMode)
Returns a
Decimal whose value is (this - unscaledSubtrahend × 10-scale) with
the scale of this Decimal. |
BigDecimal |
toBigDecimal()
|
BigDecimal |
toBigDecimal(int scale,
RoundingMode roundingMode)
Returns a
BigDecimal value of the given scale using the specified rounding mode if necessary. |
BigInteger |
toBigInteger()
Converts this
Decimal to a BigInteger. |
BigInteger |
toBigInteger(RoundingMode roundingMode)
Converts this
Decimal to a BigInteger value using the specified rounding mode if necessary. |
BigInteger |
toBigIntegerExact()
Converts this
Decimal to a BigInteger, checking for lost information. |
String |
toString()
Returns a string representation of this
Decimal object as fixed-point Decimal always showing all Decimal
places (also trailing zeros) and a leading sign character if negative. |
byteValue, shortValueclone, finalize, getClass, notify, notifyAll, wait, wait, waitbyteValue, getFactory, getScale, getScaleMetrics, multiplyExact, scale, scale, scale, scale, shortValue, toImmutableDecimal, toMutableDecimal, unscaledValuepublic AbstractDecimal()
protected abstract D createOrAssign(long unscaled)
Decimal whose value is
(unscaled × 10-scale).
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 (unscaled × 10-scale).
unscaled - unscaled value to be returned as a Decimalprotected abstract D create(long unscaled)
Decimal whose value is
(unscaled × 10-scale).unscaled - unscaled value to be returned as a Decimalprotected abstract D[] createArray(int length)
Decimal array of the specified length.length - the length of the array to returnnew D[length]protected abstract D self()
this decimal value as concrete implementation subtype.thisprotected DecimalArithmetic getDefaultArithmetic()
HALF_UP.protected DecimalArithmetic getDefaultCheckedArithmetic()
HALF_UP.protected DecimalArithmetic getArithmeticFor(OverflowMode overflowMode)
HALF_UP and the specified
overflowMode.overflowMode - the overflow for the returned arithmeticHALF_UP
rounding and the given overflowModeprotected DecimalArithmetic getRoundingDownArithmetic()
DOWN.protected DecimalArithmetic getRoundingFloorArithmetic()
FLOOR.protected DecimalArithmetic getRoundingHalfEvenArithmetic()
HALF_EVEN.protected DecimalArithmetic getRoundingUnnecessaryArithmetic()
UNNECESSARY.UNNECESSARY
rounding and UNCHECKED overflow
modeprotected DecimalArithmetic getArithmeticFor(RoundingMode roundingMode)
RoundingMode.roundingMode - the rounding for the returned arithmeticroundingMode and
UNCHECKED overflow modeprotected DecimalArithmetic getCheckedArithmeticFor(RoundingMode roundingMode)
RoundingMode.roundingMode - the rounding for the returned arithmeticroundingMode and
CHECKED overflow modeprotected DecimalArithmetic getArithmeticFor(TruncationPolicy truncationPolicy)
truncationPolicy.truncationPolicy - the truncation policy for the returned arithmetictruncationPolicypublic byte byteValueExact()
DecimalDecimal to a byte, checking for lost information. If this Decimal has a
nonzero fractional part or is out of the possible range for a byte result then an
ArithmeticException is thrown.byteValueExact in interface Decimal<S extends ScaleMetrics>Decimal converted to a byte.Decimal.byteValue()public short shortValueExact()
DecimalDecimal to a short, checking for lost information. If this Decimal has a
nonzero fractional part or is out of the possible range for a short result then an
ArithmeticException is thrown.shortValueExact in interface Decimal<S extends ScaleMetrics>Decimal converted to a short.Decimal.shortValue()public int intValue()
DecimalDecimal to an int. This conversion is analogous to the narrowing primitive
conversion from double to short as defined in section 5.1.3 of The Java™ Language
Specification: any fractional part of this Decimal will be discarded, and if the resulting
"long" is too big to fit in an int, only the low-order 32 bits are returned. Note that this
conversion can lose information about the overall magnitude and precision of this Decimal value as well
as return a result with the opposite sign.intValue in interface Decimal<S extends ScaleMetrics>intValue in class NumberDecimal converted to an int.Number.intValue(),
Decimal.intValueExact()public int intValueExact()
DecimalDecimal to an int, checking for lost information. If this Decimal has a
nonzero fractional part or is out of the possible range for an int result then an
ArithmeticException is thrown.intValueExact in interface Decimal<S extends ScaleMetrics>Decimal converted to an int.Decimal.intValue()public long longValue()
DecimalDecimal to a long. This conversion is analogous to the narrowing primitive
conversion from double to short as defined in section 5.1.3 of The Java™ Language
Specification: any fractional part of this Decimal will be discarded. Note that this conversion
can lose information about the precision of the Decimal value.
Note that this method uses RoundingMode.DOWN as defined by The Java™Language
Specification. Other rounding modes are supported via Decimal.longValue(RoundingMode).
longValue in interface Decimal<S extends ScaleMetrics>longValue in class NumberDecimal converted to a long.Number.longValue(),
Decimal.longValue(RoundingMode),
Decimal.longValueExact()public long longValueExact()
DecimalDecimal to a long, checking for lost information. If this Decimal has a
nonzero fractional part or is out of the possible range for a long result then an
ArithmeticException is thrown.longValueExact in interface Decimal<S extends ScaleMetrics>Decimal converted to a long.Decimal.longValue(),
Decimal.longValue(RoundingMode)public long longValue(RoundingMode roundingMode)
DecimalDecimal to a long using the specified rounding mode if necessary. Rounding is
applied if the Decimal value can not be represented as a long value, that is, if it has a nonzero fractional
part. Note that this conversion can lose information about the precision of the Decimal value.longValue in interface Decimal<S extends ScaleMetrics>roundingMode - the rounding mode to apply when rounding is necessary to convert this Decimal into a longDecimal converted to a long.Decimal.longValue(),
Decimal.longValueExact()public float floatValue()
DecimalDecimal to a float. This conversion is similar to the narrowing primitive
conversion from double to float as defined in section 5.1.3 of The Java™ Language
Specification. Note that this conversion can lose information about the precision of the Decimal
value.
Note that this method uses RoundingMode.HALF_EVEN as defined by The Java™Language
Specification. Other rounding modes are supported via Decimal.floatValue(RoundingMode).
floatValue in interface Decimal<S extends ScaleMetrics>floatValue in class NumberDecimal converted to a float.Number.floatValue(),
Decimal.floatValue(RoundingMode)public float floatValue(RoundingMode roundingMode)
DecimalDecimal to a float using the specified rounding mode if the Decimal value can not
be exactly represented as a float value. Note that this conversion can lose information about the precision of
the Decimal value.floatValue in interface Decimal<S extends ScaleMetrics>roundingMode - the rounding mode to apply when rounding is necessary to convert this Decimal into a float valueDecimal converted to a float.Decimal.floatValue()public double doubleValue()
DecimalDecimal to a double. This conversion is similar to the narrowing primitive
conversion from double to float as defined in section 5.1.3 of The Java™ Language
Specification. Note that this conversion can lose information about the precision of the Decimal
value.
Note that this method uses RoundingMode.HALF_EVEN as defined by The Java™Language
Specification. Other rounding modes are supported via Decimal.doubleValue(RoundingMode).
doubleValue in interface Decimal<S extends ScaleMetrics>doubleValue in class NumberDecimal converted to a double.Number.doubleValue(),
Decimal.doubleValue(RoundingMode)public double doubleValue(RoundingMode roundingMode)
DecimalDecimal to a double using the specified rounding mode if the Decimal value can not
be exactly represented as a double value. Note that this conversion can lose information about the precision of
the Decimal value.doubleValue in interface Decimal<S extends ScaleMetrics>roundingMode - the rounding mode to apply when rounding is necessary to convert this Decimal into a double valueDecimal converted to a double.Decimal.doubleValue()public BigInteger toBigInteger()
DecimalDecimal to a BigInteger. This conversion is analogous to the narrowing primitive
conversion from double to long as defined in section 5.1.3 of The Java™ Language
Specification: any fractional part of this Decimal will be discarded. Note that this conversion
can lose information about the precision of the Decimal value.
To have an exception thrown if the conversion is inexact (in other words if a nonzero fractional part is
discarded), use the Decimal.toBigIntegerExact() method.
Note that this method uses RoundingMode.DOWN to be consistent with other integer conversion methods as
defined by The Java™Language Specification. Other rounding modes are supported via
Decimal.toBigInteger(RoundingMode).
toBigInteger in interface Decimal<S extends ScaleMetrics>Decimal converted to a BigInteger.Decimal.toBigIntegerExact(),
Decimal.toBigInteger(RoundingMode),
Decimal.longValue()public BigInteger toBigIntegerExact()
DecimalDecimal to a BigInteger, checking for lost information. An exception is thrown if
this Decimal has a nonzero fractional part.toBigIntegerExact in interface Decimal<S extends ScaleMetrics>Decimal converted to a BigInteger.Decimal.toBigInteger(),
Decimal.toBigInteger(RoundingMode),
Decimal.longValueExact()public BigInteger toBigInteger(RoundingMode roundingMode)
DecimalDecimal to a BigInteger value using the specified rounding mode if necessary.
Rounding is applied if the Decimal value can not be represented as a BigInteger, that is, if it has a
nonzero fractional part. Note that this conversion can lose information about the precision of the
Decimal value.toBigInteger in interface Decimal<S extends ScaleMetrics>roundingMode - the rounding mode to apply when rounding is necessary to convert this Decimal into a
BigIntegerDecimal converted to a BigInteger.Decimal.toBigInteger(),
Decimal.toBigIntegerExact()public BigDecimal toBigDecimal()
DecimaltoBigDecimal in interface Decimal<S extends ScaleMetrics>Decimal converted to a BigDecimal with the same scale as this Decimal value.Decimal.toBigDecimal(int, RoundingMode)public BigDecimal toBigDecimal(int scale, RoundingMode roundingMode)
DecimalBigDecimal value of the given scale using the specified rounding mode if necessary.toBigDecimal in interface Decimal<S extends ScaleMetrics>scale - the scale used for the returned BigDecimalroundingMode - the rounding mode to apply when rounding is necessary to convert from the this Decimal's
scale to the target scaleBigDecimal instance of the specified scaleDecimal.toBigDecimal()public D 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)public D 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()public D 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)public D 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)public D 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)public D 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 + augendpublic D 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 + augendpublic D 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 necessarypublic D 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)public D 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 + augendpublic D 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 + augendpublic D 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 Decimalpublic D 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)public D 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 Decimalpublic D 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 overflowpublic D 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 tenpublic D 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 necessarypublic D 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 additionpublic D 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 Decimalpublic D 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 valuepublic D 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 operationpublic D 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 - subtrahendpublic D 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 - subtrahendpublic D 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 necessarypublic D 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 subtractionpublic D 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 - subtrahendpublic D 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 - subtrahendpublic D 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 Decimalpublic D 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 Decimalpublic D 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 Decimalpublic D 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 overflowpublic D 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 tenpublic D 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 necessarypublic D 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 subtractionpublic D 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 Decimalpublic D 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 valuepublic D 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 operationpublic D 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 Decimalpublic D 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 roundedpublic D 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 occurspublic D 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 Decimalpublic D 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 necessarypublic D 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 occurspublic D 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)public D 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)public D 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 Decimalpublic D 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))public D 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 Decimalpublic D 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 roundedpublic D 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 occurspublic D 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 tenpublic D 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 necessarypublic D 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 occurspublic D 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 Decimalpublic D 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 < 0public D 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
multiplicationpublic D 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 dividedpublic D 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)public D 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 occurspublic D 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 dividedpublic D 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)public D 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)public D 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 dividedpublic D 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)public D 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 occurspublic D 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 dividedpublic D 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))public D 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 dividedpublic D 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 roundedpublic D 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 occurspublic D 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 tenpublic D 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 roundedpublic D 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 occurspublic D 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 / divisorpublic D 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 dividedpublic D 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 dividedpublic D 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 > 0public D 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 multiplicationpublic D 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)public D 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)public long divideToLongValue(Decimal<S> divisor)
DecimalDecimal whose value (this / divisor) rounded down to the next long value. If
the division causes an overflow, the result is silently truncated.divideToLongValue in interface Decimal<S extends ScaleMetrics>divisor - value by which this Decimal is to be divided.(this / divisor) returned as longDecimal.divideToLongValue(Decimal, OverflowMode),
Decimal.divideToIntegralValue(Decimal),
Decimal.remainder(Decimal)public long divideToLongValue(Decimal<S> divisor, OverflowMode overflowMode)
DecimalDecimal whose value (this / divisor) rounded down to the next long value. The
specified overflowMode determines whether to truncate the result silently or to throw an exception if an
overflow occurs.divideToLongValue 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) returned as longDecimal.divideToLongValue(Decimal),
Decimal.divideToIntegralValue(Decimal),
Decimal.remainder(Decimal)public D[] 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)public D[] 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)public D 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)public int signum()
DecimalDecimal.signum in interface Decimal<S extends ScaleMetrics>Decimal is negative, zero, or positive.public D 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>-thispublic D 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-thispublic D 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)public D 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)public D 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>public D 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)public D 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)public D 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>public D 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)public D 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)public D 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)public D 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)public D 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)public D 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)public D 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)public D 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)public D 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)public D 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)public D 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 topublic D 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 necessarypublic D 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 occurspublic int compareTo(Decimal<S> other)
DecimalDecimal objects numerically.compareTo in interface Comparable<Decimal<S extends ScaleMetrics>>compareTo in interface Decimal<S extends ScaleMetrics>other - Decimal to which this Decimal is to be compared0 if this Decimal is equal to the argument Decimal; a value less than
0 if this Decimal is numerically less than the argument Decimal; and a value
greater than 0 if this Decimal is numerically greater than the argument Decimalpublic boolean isEqualTo(Decimal<S> other)
DecimalDecimal with the specified Decimal and returns true if the two are numerically
equal.
Returns true iff Decimal.compareTo(Decimal) returns 0.
isEqualTo in interface Decimal<S extends ScaleMetrics>other - Decimal to which this Decimal is to be comparedDecimal is numerically equal to other and false otherwisepublic boolean isGreaterThan(Decimal<S> other)
DecimalDecimal with the specified Decimal and returns true if this Decimal is numerically
greater than other.
Returns true iff Decimal.compareTo(Decimal) returns a value greater than 0.
isGreaterThan in interface Decimal<S extends ScaleMetrics>other - Decimal to which this Decimal is to be comparedthis > otherpublic boolean isGreaterThanOrEqualTo(Decimal<S> other)
DecimalDecimal with the specified Decimal and returns true if this Decimal is numerically
greater than or equal to other.
Returns true iff Decimal.compareTo(Decimal) returns a non-negative value.
isGreaterThanOrEqualTo in interface Decimal<S extends ScaleMetrics>other - Decimal to which this Decimal is to be comparedthis >= otherpublic boolean isLessThan(Decimal<S> other)
DecimalDecimal with the specified Decimal and returns true if this Decimal is numerically
less than other.
Returns true iff Decimal.compareTo(Decimal) returns a negative value.
isLessThan in interface Decimal<S extends ScaleMetrics>other - Decimal to which this Decimal is to be compared.this < otherpublic boolean isLessThanOrEqualTo(Decimal<S> other)
DecimalDecimal with the specified Decimal and returns true if this Decimal is numerically
less than or equal to other.
Returns true iff Decimal.compareTo(Decimal) returns a non-positive value.
isLessThanOrEqualTo in interface Decimal<S extends ScaleMetrics>other - Decimal to which this Decimal is to be comparedthis <= otherpublic boolean isZero()
DecimalDecimal is zero.isZero in interface Decimal<S extends ScaleMetrics>this == 0public boolean isOne()
DecimalDecimal is one.isOne in interface Decimal<S extends ScaleMetrics>this == 1public boolean isUlp()
DecimalDecimal is equal to the smallest positive number representable by a Decimal with the
current scale.isUlp in interface Decimal<S extends ScaleMetrics>unscaledValue() == 1public boolean isMinusOne()
DecimalDecimal is minus one.isMinusOne in interface Decimal<S extends ScaleMetrics>this == -1public boolean isPositive()
DecimalDecimal is strictly positive.isPositive in interface Decimal<S extends ScaleMetrics>this > 0public boolean isNonNegative()
DecimalDecimal is not negative.isNonNegative in interface Decimal<S extends ScaleMetrics>this >= 0public boolean isNegative()
DecimalDecimal is negative.isNegative in interface Decimal<S extends ScaleMetrics>this < 0public boolean isNonPositive()
DecimalDecimal is not positive.isNonPositive in interface Decimal<S extends ScaleMetrics>this <= 0public boolean isIntegral()
DecimalDecimal number is integral, or equivalently if its fractional part is zero.isIntegral in interface Decimal<S extends ScaleMetrics>this is an integer numberpublic boolean isIntegralPartZero()
Decimalintegral part of this Decimal number is zero.isIntegralPartZero in interface Decimal<S extends ScaleMetrics>-1 < this < 1public boolean isBetweenZeroAndOne()
DecimalDecimal is between zero (inclusive) and one (exclusive). The result value is true if
and only if this Decimal is not negative and its integral part is zero.isBetweenZeroAndOne in interface Decimal<S extends ScaleMetrics>0 <= this < 1public boolean isBetweenZeroAndMinusOne()
DecimalDecimal is between zero (inclusive) and minus one (exclusive). The result value is
true if and only if this Decimal is not positive and its integral part is zero.isBetweenZeroAndMinusOne in interface Decimal<S extends ScaleMetrics>-1 < this <= 0public int compareToNumerically(Decimal<?> other)
DecimalDecimal with the specified Decimal. Two Decimal objects that are equal in
value but have a different scale (like 2.0 and 2.00) are considered equal by this method.compareToNumerically in interface Decimal<S extends ScaleMetrics>other - Decimal to which this Decimal is to be compared.0 if this Decimal is equal to the argument Decimal; a value less than
0 if this Decimal is numerically less than the argument Decimal; and a value
greater than 0 if this Decimal is numerically greater than the argument DecimalDecimal.isEqualToNumerically(Decimal),
Decimal.compareTo(Decimal)public boolean isEqualToNumerically(Decimal<?> other)
DecimalDecimal with the specified Decimal and returns true if the two are numerically
equal. Two Decimal objects that are equal in value but have a different scale (like 2.0 and 2.00) are
considered equal by this method as opposed to the equals method which requires identical
scales of the compared values.
Returns true iff Decimal.compareToNumerically(Decimal) returns 0.
isEqualToNumerically in interface Decimal<S extends ScaleMetrics>other - Decimal to which this Decimal is to be compared.Decimal is numerically equal to other and false otherwise.Decimal.compareToNumerically(Decimal),
Decimal.compareTo(Decimal)public Decimal<S> min(Decimal<S> val)
DecimalDecimal and val.min in interface Decimal<S extends ScaleMetrics>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)public Decimal<S> max(Decimal<S> val)
DecimalDecimal and val.max in interface Decimal<S extends ScaleMetrics>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)public D min(D 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.compareTo(Decimal)public D max(D 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.compareTo(Decimal)public D 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.public D 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)public boolean equals(Object obj)
Decimaltrue if and only if the argument is a
Decimal value with the same scale and unscaled value as this
Decimal.equals in interface Decimal<S extends ScaleMetrics>equals in class Objectobj - the object to compare withtrue if the argument is a Decimal object that contains the same value and scale as this
object; false otherwiseDecimal.isEqualTo(Decimal),
Decimal.isEqualToNumerically(Decimal),
Decimal.hashCode()