S - the scale metrics type associated with this decimalD - the concrete class implementing this ImmutableDecimalpublic abstract class AbstractImmutableDecimal<S extends ScaleMetrics,D extends AbstractImmutableDecimal<S,D>> extends AbstractDecimal<S,D> implements ImmutableDecimal<S>
Decimal classes of different scales.| Constructor and Description |
|---|
AbstractImmutableDecimal(long unscaled)
Constructor with unscaled value.
|
| Modifier and Type | Method and Description |
|---|---|
ImmutableDecimal<S> |
max(ImmutableDecimal<S> val)
Returns the maximum of this
Decimal and val. |
ImmutableDecimal<S> |
min(ImmutableDecimal<S> val)
Returns the minimum of this
Decimal and val. |
ImmutableDecimal<?> |
multiplyExact(Decimal<?> multiplicand)
Returns a
Decimal whose value is (this * multiplicand). |
ImmutableDecimal<?> |
scale(int scale)
|
ImmutableDecimal<?> |
scale(int scale,
RoundingMode roundingMode)
|
<S extends ScaleMetrics> |
scale(S scaleMetrics)
|
<S extends ScaleMetrics> |
scale(S scaleMetrics,
RoundingMode roundingMode)
|
long |
unscaledValue()
Returns the unscaled value underlying this
Decimal. |
abs, abs, add, add, add, add, add, add, add, add, addSquared, addSquared, addSquared, addUnscaled, addUnscaled, addUnscaled, addUnscaled, addUnscaled, avg, avg, byteValueExact, compareTo, compareToNumerically, create, createArray, createOrAssign, divide, divide, divide, divide, divide, divide, divide, divide, divideAndRemainder, divideAndRemainder, divideBy, divideBy, divideBy, divideByPowerOfTen, divideByPowerOfTen, divideByPowerOfTen, divideExact, divideToIntegralValue, divideToIntegralValue, divideToLongValue, divideToLongValue, divideTruncate, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, doubleValue, doubleValue, equals, floatValue, floatValue, fractionalPart, getArithmeticFor, getArithmeticFor, getArithmeticFor, getCheckedArithmeticFor, getDefaultArithmetic, getDefaultCheckedArithmetic, getRoundingDownArithmetic, getRoundingFloorArithmetic, getRoundingHalfEvenArithmetic, getRoundingUnnecessaryArithmetic, hashCode, integralPart, intValue, intValueExact, invert, invert, invert, isBetweenZeroAndMinusOne, isBetweenZeroAndOne, isEqualTo, isEqualToNumerically, isGreaterThan, isGreaterThanOrEqualTo, isIntegral, isIntegralPartZero, isLessThan, isLessThanOrEqualTo, isMinusOne, isNegative, isNonNegative, isNonPositive, isOne, isPositive, isUlp, isZero, longValue, longValue, longValueExact, max, max, min, min, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiplyBy, multiplyBy, multiplyBy, multiplyByPowerOfTen, multiplyByPowerOfTen, multiplyByPowerOfTen, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, negate, negate, pow, pow, pow, remainder, round, round, round, self, shiftLeft, shiftLeft, shiftLeft, shiftRight, shiftRight, shiftRight, shortValueExact, signum, sqrt, sqrt, square, square, square, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtractSquared, subtractSquared, subtractSquared, subtractUnscaled, subtractUnscaled, subtractUnscaled, subtractUnscaled, subtractUnscaled, toBigDecimal, toBigDecimal, toBigInteger, toBigInteger, toBigIntegerExact, toStringbyteValue, shortValueclone, finalize, getClass, notify, notifyAll, wait, wait, waitabs, abs, add, add, add, add, add, add, add, add, addSquared, addSquared, addSquared, addUnscaled, addUnscaled, addUnscaled, addUnscaled, addUnscaled, avg, avg, divide, divide, divide, divide, divide, divide, divide, divide, divideAndRemainder, divideAndRemainder, divideBy, divideBy, divideBy, divideByPowerOfTen, divideByPowerOfTen, divideByPowerOfTen, divideExact, divideToIntegralValue, divideToIntegralValue, divideTruncate, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, fractionalPart, integralPart, invert, invert, invert, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiplyBy, multiplyBy, multiplyBy, multiplyByPowerOfTen, multiplyByPowerOfTen, multiplyByPowerOfTen, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, negate, negate, pow, pow, pow, remainder, round, round, round, shiftLeft, shiftLeft, shiftLeft, shiftRight, shiftRight, shiftRight, sqrt, sqrt, square, square, square, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtractSquared, subtractSquared, subtractSquared, subtractUnscaled, subtractUnscaled, subtractUnscaled, subtractUnscaled, subtractUnscaledbyteValue, byteValueExact, compareTo, compareToNumerically, divideToLongValue, divideToLongValue, doubleValue, doubleValue, equals, floatValue, floatValue, getFactory, getScale, getScaleMetrics, hashCode, intValue, intValueExact, isBetweenZeroAndMinusOne, isBetweenZeroAndOne, isEqualTo, isEqualToNumerically, isGreaterThan, isGreaterThanOrEqualTo, isIntegral, isIntegralPartZero, isLessThan, isLessThanOrEqualTo, isMinusOne, isNegative, isNonNegative, isNonPositive, isOne, isPositive, isUlp, isZero, longValue, longValue, longValueExact, max, min, shortValue, shortValueExact, signum, toBigDecimal, toBigDecimal, toBigInteger, toBigInteger, toBigIntegerExact, toImmutableDecimal, toMutableDecimal, toStringpublic AbstractImmutableDecimal(long unscaled)
unscaled - the unscaled valuepublic final long unscaledValue()
DecimalDecimal. This
Decimal is (unscaledValue × 10-f) with
f representing the scale, hence the returned
value equals (10f × this).unscaledValue in interface Decimal<S extends ScaleMetrics>Decimal.getScale(),
ScaleMetrics.getScaleFactor()public ImmutableDecimal<?> scale(int scale)
DecimalDecimal value whose scale is
changed to the given scale value. HALF_UP rounding is used if the scale change involves rounding.
An exception is thrown if the scale conversion leads to an overflow.
scale in interface Decimal<S extends ScaleMetrics>scale in interface ImmutableDecimal<S extends ScaleMetrics>scale - the scale to use for the result, must be in [0,18]Decimal.scale(ScaleMetrics),
Decimal.scale(int, RoundingMode),
Decimal.round(int)public <S extends ScaleMetrics> ImmutableDecimal<S> scale(S scaleMetrics)
DecimalDecimal value whose scale is
changed to the scale given by the scaleMetrics argument.
HALF_UP rounding is used if the scale change
involves rounding.
An exception is thrown if the scale conversion leads to an overflow.
scale in interface Decimal<S extends ScaleMetrics>scale in interface ImmutableDecimal<S extends ScaleMetrics>S - the scale metrics type of the resultscaleMetrics - the scale metrics to use for the resultDecimal.scale(int),
Decimal.scale(ScaleMetrics, RoundingMode),
Decimal.round(int)public ImmutableDecimal<?> scale(int scale, RoundingMode roundingMode)
DecimalDecimal value whose scale is
changed to the given scale value. The specified
roundingMode is used if the scale change involves rounding.
An exception is thrown if the scale conversion leads to an overflow.
scale in interface Decimal<S extends ScaleMetrics>scale in interface ImmutableDecimal<S extends ScaleMetrics>scale - the scale to use for the result, must be in [0,18]roundingMode - the rounding mode to apply if the scale change involves
roundingDecimal.scale(int),
Decimal.scale(ScaleMetrics, RoundingMode),
Decimal.round(int, RoundingMode)public <S extends ScaleMetrics> ImmutableDecimal<S> scale(S scaleMetrics, RoundingMode roundingMode)
DecimalDecimal value whose scale is
changed to the scale given by the scaleMetrics argument. The
specified roundingMode is used if the scale change involves
rounding.
An exception is thrown if the scale conversion leads to an overflow.
scale in interface Decimal<S extends ScaleMetrics>scale in interface ImmutableDecimal<S extends ScaleMetrics>S - the scale metrics type of the resultscaleMetrics - the scale metrics to use for the resultroundingMode - the rounding mode to apply if the scale change involves
roundingDecimal.scale(ScaleMetrics),
Decimal.scale(int, RoundingMode),
Decimal.round(int, RoundingMode)public ImmutableDecimal<?> multiplyExact(Decimal<?> multiplicand)
DecimalDecimal whose value is (this * multiplicand).
The scale of the returned value is the sum of the scales of this
Decimal and the multiplicand argument. If the result scale
exceeds 18, an IllegalArgumentException is thrown. An
ArithmeticException is thrown if the product is out of the
possible range for a Decimal with the result scale.
Note that the result is always a new instance --- immutable if
this Decimal is an ImmutableDecimal and mutable if it is a
MutableDecimal.
multiplyExact in interface Decimal<S extends ScaleMetrics>multiplyExact in interface ImmutableDecimal<S extends ScaleMetrics>multiplicand - factor to multiply with this Decimal(this * multiplicand) with scale equal to the sum of
scales of this and multiplicandpublic ImmutableDecimal<S> min(ImmutableDecimal<S> val)
ImmutableDecimalDecimal and val.min in interface ImmutableDecimal<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 ImmutableDecimal<S> max(ImmutableDecimal<S> val)
ImmutableDecimalDecimal and val.max in interface ImmutableDecimal<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)