- java.lang.Object
-
- life.expert.value.numeric.amount.RoundedAmount
-
-
Field Summary
Fields Modifier and Type Field Description static AmountContextDEFAULT_CONTEXTThe constant DEFAULT_CONTEXT.
-
Constructor Summary
Constructors Constructor Description RoundedAmount(java.lang.Number number, Unit unit)Creates a new instance osRoundedAmount.RoundedAmount(java.lang.Number number, Unit unit, java.math.MathContext mathContext)Deprecated.RoundedAmount(java.lang.Number number, Unit unit, AmountContext mathContext)Instantiates a new Rounded amount.RoundedAmount(java.lang.Number number, Unit unit, AmountContext context, Operator rounding)Deprecated.RoundedAmount(java.lang.Number number, Unit unit, Operator rounding)Creates a new instance osRoundedAmount.
-
Method Summary
Modifier and Type Method Description RoundedAmountabs()Returns aQuantitywhose value is the absolute value of thisQuantity, and whose scale isthis.scale().RoundedAmountadd(Quantity amount)Add rounded unit.java.math.BigDecimalasNumberStripped()Method that returns BigDecimal.ZERO, ifisZero(), and #numberstripTrailingZeros()in all other cases.<T> TasType(java.lang.Class<T> type)Deprecated.<T> TasType(java.lang.Class<T> type, Operator adjuster)Deprecated.intcompareTo(Quantity o)Compare to int.RoundedAmountdivide(double divisor)Returns aQuantitywhose value isRoundedAmountdivide(long divisor)Returns aQuantitywhose value isRoundedAmountdivide(java.lang.Number divisor)Returns aQuantitywhose value isRoundedAmount[]divideAndRemainder(double divisor)Returns a two-elementQuantityarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands.RoundedAmount[]divideAndRemainder(long divisor)Returns a two-elementQuantityarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands.RoundedAmount[]divideAndRemainder(java.lang.Number divisor)Returns a two-elementQuantityarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands.RoundedAmountdivideToIntegralValue(double divisor)Returns aQuantitywhose value is the integer part of the quotientRoundedAmountdivideToIntegralValue(long divisor)Returns aQuantitywhose value is the integer part of the quotientRoundedAmountdivideToIntegralValue(java.lang.Number divisor)Returns aQuantitywhose value is the integer part of the quotientbooleanequals(java.lang.Object obj)static RoundedAmountfrom(Quantity amt)From rounded unit.AmountContextgetContext()Access theMathContextused by this instance.NumberValuegetNumber()Gets the correspondingNumberValue.intgetPrecision()Gets precision.intgetScale()Gets scale.UnitgetUnit()Gets unit.inthashCode()booleanisEqualTo(Quantity amount)Is equal to boolean.booleanisGreaterThan(Quantity amount)Is greater than boolean.booleanisGreaterThanOrEqualTo(Quantity amount)Is greater than or equal to boolean.booleanisLessThan(Quantity amount)Is less than boolean.booleanisLessThanOrEqualTo(Quantity amount)Is less than or equal to boolean.booleanisNegative()Checks if aQuantityis negative.booleanisNegativeOrZero()Checks if aQuantityis negative or zero.booleanisNotEqualTo(Quantity amount)Is not equal to boolean.booleanisPositive()Checks if aQuantityis positive.booleanisPositiveOrZero()Checks if aQuantityis positive or zero.booleanisZero()Checks if anQuantityis zero.RoundedAmountmultiply(double multiplicand)Returns aQuantitywhose value is (this × multiplicand), and whose scale isRoundedAmountmultiply(long multiplicand)Returns aQuantitywhose value is (this × multiplicand), and whose scale isRoundedAmountmultiply(java.lang.Number multiplicand)Returns aQuantitywhose value is (this × multiplicand) , and whose scale isRoundedAmountnegate()Returns aQuantitywhose value isstatic RoundedAmountof(java.lang.Number number, java.lang.String unitCode)Deprecated.static RoundedAmountof(java.lang.Number number, java.lang.String unitCode, AmountContext amountContext)Deprecated.static RoundedAmountof(java.lang.Number number, java.lang.String unitCode, Operator rounding)Static factory method for creating a new instance ofRoundedAmount.static RoundedAmountof(java.lang.Number number, Unit unit, AmountContext amountContext)Static factory method for creating a new instance ofRoundedAmount.static RoundedAmountof(java.lang.Number number, Unit unit, Operator rounding)Static factory method for creating a new instance ofRoundedAmount.static RoundedAmountof(java.lang.String unitCode, java.lang.Number number, AmountContext amountContext, Operator rounding)Static factory method for creating a new instance ofRoundedAmount.static RoundedAmountof(java.math.BigDecimal number, Unit unit)Translates aBigDecimalvalue and aUnitunit into aAmount.static RoundedAmountof(java.math.BigDecimal number, Unit unit, java.math.MathContext mathContext)Translates aBigDecimalvalue and aUnitunit into aAmount.static RoundedAmountof(java.math.BigDecimal number, Unit unit, Operator rounding)Translates aBigDecimalvalue and aUnitunit into aAmount.static RoundedAmountof(Unit unit, java.lang.Number number, AmountContext amountContext, Operator rounding)Deprecated.static RoundedAmountofMinor(Unit unit, long amountMinor)Obtains an instance ofRoundedAmountfrom an amount in minor units.static RoundedAmountofMinor(Unit unit, long amountMinor, int factionDigits)Obtains an instance ofRoundedAmountfrom an amount in minor units.static RoundedAmountparse(java.lang.CharSequence text)Obtains an instance of RoundedAmount from a text string such as 'EUR 25.25'.RoundedAmountplus()Returns aQuantitywhose value isRoundedAmountpow(int n)Pow rounded unit.RoundedAmountremainder(double divisor)Returns aQuantitywhose value isRoundedAmountremainder(long divisor)Returns aQuantitywhose value isRoundedAmountremainder(java.lang.Number divisor)Returns aQuantitywhose value isRoundedAmountscaleByPowerOfTen(int power)Returns aQuantitywhose numerical value is equal to (this* 10n).intsignum()Returns the signum function of thisQuantity.RoundedAmountstripTrailingZeros()Returns aQuantitywhich is numerically equal to this one but with any trailing zeros removed from the representation.RoundedAmountsubtract(Quantity amount)Subtract rounded unit.java.lang.StringtoString()RoundedAmountulp()Ulp rounded unit.RoundedAmountwith(java.lang.Number amount)With rounded unit.RoundedAmountwith(Operator operator)With rounded unit.RoundedAmountwith(Unit unit)Creates a new Amount instance, by just replacing theUnit.RoundedAmountwith(Unit unit, java.lang.Number amount)With rounded unit.static RoundedAmountzero(Unit unit)Obtains an instance ofRoundedAmountrepresenting zero.
-
-
-
Field Detail
-
DEFAULT_CONTEXT
public static final AmountContext DEFAULT_CONTEXT
The constant DEFAULT_CONTEXT.
-
-
Constructor Detail
-
RoundedAmount
public RoundedAmount(java.lang.Number number, Unit unit)Creates a new instance osRoundedAmount.- Parameters:
number- the amount, not null.unit- the unit, not null.
-
RoundedAmount
@Deprecated public RoundedAmount(java.lang.Number number, Unit unit, java.math.MathContext mathContext)Deprecated.Instantiates a new Rounded unit.- Parameters:
number- the numberunit- the unitmathContext- the math context
-
RoundedAmount
public RoundedAmount(java.lang.Number number, Unit unit, AmountContext mathContext)Instantiates a new Rounded amount.- Parameters:
number- the numberunit- the unitmathContext- the math context
-
RoundedAmount
public RoundedAmount(java.lang.Number number, Unit unit, Operator rounding)Creates a new instance osRoundedAmount.- Parameters:
number- the amount, not null.unit- , not null.rounding- the rounding
-
RoundedAmount
@Deprecated public RoundedAmount(java.lang.Number number, Unit unit, AmountContext context, Operator rounding)Deprecated.Instantiates a new Rounded unit.- Parameters:
number- the numberunit- the unitcontext- the contextrounding- the rounding
-
-
Method Detail
-
ulp
public RoundedAmount ulp()
Ulp rounded unit.- Returns:
- the rounded unit
-
pow
public RoundedAmount pow(int n)
Pow rounded unit.- Parameters:
n- the n- Returns:
- the rounded unit
-
with
public RoundedAmount with(java.lang.Number amount)
With rounded unit.- Parameters:
amount- the amount- Returns:
- the rounded unit
-
with
public RoundedAmount with(Unit unit)
Creates a new Amount instance, by just replacing theUnit.- Parameters:
unit- the unit unit to be replaced, notnull- Returns:
- the new amount with the same numeric value and
MathContext, but the newUnit.
-
with
public RoundedAmount with(Unit unit, java.lang.Number amount)
With rounded unit.- Parameters:
unit- the unitamount- the amount- Returns:
- the rounded unit
-
getScale
public int getScale()
Gets scale.- Returns:
- the scale
-
getPrecision
public int getPrecision()
Gets precision.- Returns:
- the precision
-
asType
@Deprecated public <T> T asType(java.lang.Class<T> type)
Deprecated.As type t.- Type Parameters:
T- the type parameter- Parameters:
type- the type- Returns:
- the t
-
asType
@Deprecated public <T> T asType(java.lang.Class<T> type, Operator adjuster)Deprecated.As type t.- Type Parameters:
T- the type parameter- Parameters:
type- the typeadjuster- the adjuster- Returns:
- the t
-
asNumberStripped
public java.math.BigDecimal asNumberStripped()
Method that returns BigDecimal.ZERO, ifisZero(), and #numberstripTrailingZeros()in all other cases.- Returns:
- the stripped number value.
-
of
public static RoundedAmount of(java.math.BigDecimal number, Unit unit)
Translates aBigDecimalvalue and aUnitunit into aAmount.- Parameters:
number- numeric value of theAmount.unit- unit unit of theAmount.- Returns:
- a
Amountcombining the numeric value and unit unit.
-
of
public static RoundedAmount of(java.math.BigDecimal number, Unit unit, Operator rounding)
Translates aBigDecimalvalue and aUnitunit into aAmount.- Parameters:
number- numeric value of theAmount.unit- unit unit of theAmount.rounding- The rounding to be applied.- Returns:
- a
Amountcombining the numeric value and unit unit.
-
of
public static RoundedAmount of(java.math.BigDecimal number, Unit unit, java.math.MathContext mathContext)
Translates aBigDecimalvalue and aUnitunit into aAmount.- Parameters:
number- numeric value of theAmount.unit- unit unit of theAmount.mathContext- theMathContextto be used.- Returns:
- a
Amountcombining the numeric value and unit unit.
-
of
public static RoundedAmount of(java.lang.Number number, Unit unit, Operator rounding)
Static factory method for creating a new instance ofRoundedAmount.- Parameters:
number- The numeric part, not null.unit- The target unit, not null.rounding- The rounding to be applied.- Returns:
- A new instance of
RoundedAmount.
-
of
public static RoundedAmount of(java.lang.Number number, Unit unit, AmountContext amountContext)
Static factory method for creating a new instance ofRoundedAmount.- Parameters:
number- The numeric part, not null.unit- The target unit, not null.amountContext- the monetary context- Returns:
- A new instance of
RoundedAmount.
-
of
@Deprecated public static RoundedAmount of(Unit unit, java.lang.Number number, AmountContext amountContext, Operator rounding)
Deprecated.Static factory method for creating a new instance ofRoundedAmount.- Parameters:
unit- The target unit, not null.number- The numeric part, not null.amountContext- theAmountContextto be used.rounding- The rounding to be applied.- Returns:
- A new instance of
RoundedAmount.
-
of
@Deprecated public static RoundedAmount of(java.lang.Number number, java.lang.String unitCode)
Deprecated.Static factory method for creating a new instance ofRoundedAmount.- Parameters:
number- The numeric part, not null.unitCode- The target unit as ISO unit code.- Returns:
- A new instance of
RoundedAmount.
-
of
public static RoundedAmount of(java.lang.Number number, java.lang.String unitCode, Operator rounding)
Static factory method for creating a new instance ofRoundedAmount.- Parameters:
number- The numeric part, not null.unitCode- The target unit as ISO unit code.rounding- The rounding to be applied.- Returns:
- A new instance of
RoundedAmount.
-
of
@Deprecated public static RoundedAmount of(java.lang.Number number, java.lang.String unitCode, AmountContext amountContext)
Deprecated.Static factory method for creating a new instance ofRoundedAmount.- Parameters:
number- The numeric part, not null.unitCode- The target unit as ISO unit code.amountContext- the monetary context- Returns:
- A new instance of
RoundedAmount.
-
of
public static RoundedAmount of(java.lang.String unitCode, java.lang.Number number, AmountContext amountContext, Operator rounding)
Static factory method for creating a new instance ofRoundedAmount.- Parameters:
unitCode- The target unit as ISO unit code.number- The numeric part, not null.amountContext- the monetary contextrounding- The rounding to be applied.- Returns:
- A new instance of
RoundedAmount.
-
zero
public static RoundedAmount zero(Unit unit)
Obtains an instance ofRoundedAmountrepresenting zero.- Parameters:
unit- the unit, not null.- Returns:
- an instance of
RoundedAmountrepresenting zero. - Since:
- 1.0.1
-
ofMinor
public static RoundedAmount ofMinor(Unit unit, long amountMinor)
Obtains an instance ofRoundedAmountfrom an amount in minor units. For example,ofMinor(USD, 1234)creates the instanceUSD 12.34.- Parameters:
unit- the unit, not nullamountMinor- the amount of unit in the minor division of the unit- Returns:
- the Amount from minor units
- Throws:
java.lang.NullPointerException- when the unit is nulljava.lang.IllegalArgumentException- whenUnit.getDefaultFractionDigits()is lesser than zero.- Since:
- 1.0.1
- See Also:
Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()
-
ofMinor
public static RoundedAmount ofMinor(Unit unit, long amountMinor, int factionDigits)
Obtains an instance ofRoundedAmountfrom an amount in minor units. For example,ofMinor(USD, 1234, 2)creates the instanceUSD 12.34.- Parameters:
unit- the unit, not nullamountMinor- the amount of unit in the minor division of the unitfactionDigits- number of digits- Returns:
- the monetary amount from minor units
- Throws:
java.lang.NullPointerException- when the unit is nulljava.lang.IllegalArgumentException- when the factionDigits is negative- Since:
- 1.0.1
- See Also:
Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits()Unit#getDefaultFractionDigits(),Amount#ofMinor(Unit , long , int)Amount#ofMinor(Unit , long , int)Amount#ofMinor(Unit , long , int)Amount#ofMinor(Unit , long , int)Amount#ofMinor(Unit , long , int)Amount#ofMinor(Unit, long, int)
-
from
public static RoundedAmount from(Quantity amt)
From rounded unit.- Parameters:
amt- the amt- Returns:
- the rounded unit
-
parse
public static RoundedAmount parse(java.lang.CharSequence text)
Obtains an instance of RoundedAmount from a text string such as 'EUR 25.25'.- Parameters:
text- the input text, not null.- Returns:
- RoundedAmount instance
- Throws:
java.lang.NumberFormatException- if the amount is not a numberUnknownUnitException- the unit cannot be resolved
-
getUnit
public Unit getUnit()
Gets unit.
-
getContext
public AmountContext getContext()
Access theMathContextused by this instance.- Specified by:
getContextin interfaceQuantity- Returns:
- the
MathContextused, never null.
-
abs
public RoundedAmount abs()
Description copied from interface:QuantityReturns aQuantitywhose value is the absolute value of thisQuantity, and whose scale isthis.scale().
-
add
public RoundedAmount add(Quantity amount)
Add rounded unit.
-
divide
public RoundedAmount divide(java.lang.Number divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is
, and whose preferred scale isthis / divisor
; if the exact quotient cannot be represented anthis.scale() - divisor.scale()ArithmeticExceptionis thrown.
-
divideAndRemainder
public RoundedAmount[] divideAndRemainder(java.lang.Number divisor)
Description copied from interface:QuantityReturns a two-elementQuantityarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands. Note that if both the integer quotient and remainder are needed, this method is faster than using thedivideToIntegralValueandremaindermethods separately because the division need only be carried out once.- Specified by:
divideAndRemainderin interfaceQuantity- Parameters:
divisor- value by which thisQuantityis to be divided, and the remainder computed.- Returns:
- a two element
Quantityarray: the quotient (the result ofdivideToIntegralValue) is the initial element and the remainder is the final element. - See Also:
#divideToIntegralValue(Number)#divideToIntegralValue(Number)#divideToIntegralValue(Number)#divideToIntegralValue(Number)#divideToIntegralValue(Number),#remainder(Number)#remainder(Number)#remainder(Number)#remainder(Number)#remainder(Number)
-
divideToIntegralValue
public RoundedAmount divideToIntegralValue(java.lang.Number divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is the integer part of the quotient
rounded down. The preferred scale of the result isthis / divisor
.this.scale() - divisor.scale()- Specified by:
divideToIntegralValuein interfaceQuantity- Parameters:
divisor- value by which thisBigDecimalis to be divided.- Returns:
- The integer part of
this / divisor. - See Also:
java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)
-
multiply
public RoundedAmount multiply(java.lang.Number multiplicand)
Description copied from interface:QuantityReturns aQuantitywhose value is (this × multiplicand) , and whose scale is
.this.scale() + multiplicand.scale()
-
negate
public RoundedAmount negate()
Description copied from interface:QuantityReturns aQuantitywhose value is
, and whose scale is-thisthis.scale().
-
plus
public RoundedAmount plus()
Description copied from interface:QuantityReturns aQuantitywhose value is
, with rounding according to the context settings.+this
-
subtract
public RoundedAmount subtract(Quantity amount)
Subtract rounded unit.
-
remainder
public RoundedAmount remainder(java.lang.Number divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is
. The remainder is given bythis % divisor
. Note that this is not the modulo operation (the result can be negative).this.subtract(this.divideToIntegralValue(divisor).multiply(divisor)
-
scaleByPowerOfTen
public RoundedAmount scaleByPowerOfTen(int power)
Description copied from interface:QuantityReturns aQuantitywhose numerical value is equal to (this* 10n). The scale of the result is
.this.scale() - n- Specified by:
scaleByPowerOfTenin interfaceQuantity- Parameters:
power- the power.- Returns:
- the calculated amount value.
-
isZero
public boolean isZero()
Description copied from interface:QuantityChecks if anQuantityis zero.
-
isPositive
public boolean isPositive()
Description copied from interface:QuantityChecks if aQuantityis positive.- Specified by:
isPositivein interfaceQuantity- Returns:
true if signum() > 0.
-
isPositiveOrZero
public boolean isPositiveOrZero()
Description copied from interface:QuantityChecks if aQuantityis positive or zero.- Specified by:
isPositiveOrZeroin interfaceQuantity- Returns:
true if signum() >= 0
-
isNegative
public boolean isNegative()
Description copied from interface:QuantityChecks if aQuantityis negative.- Specified by:
isNegativein interfaceQuantity- Returns:
true if signum() <0
-
isNegativeOrZero
public boolean isNegativeOrZero()
Description copied from interface:QuantityChecks if aQuantityis negative or zero.- Specified by:
isNegativeOrZeroin interfaceQuantity- Returns:
true if signum() <= 0.
-
signum
public int signum()
Description copied from interface:QuantityReturns the signum function of thisQuantity.
-
isLessThan
public boolean isLessThan(Quantity amount)
Is less than boolean.- Specified by:
isLessThanin interfaceQuantity- Parameters:
amount- the amount- Returns:
- the boolean
-
isLessThanOrEqualTo
public boolean isLessThanOrEqualTo(Quantity amount)
Is less than or equal to boolean.- Specified by:
isLessThanOrEqualToin interfaceQuantity- Parameters:
amount- the amount- Returns:
- the boolean
-
isGreaterThan
public boolean isGreaterThan(Quantity amount)
Is greater than boolean.- Specified by:
isGreaterThanin interfaceQuantity- Parameters:
amount- the amount- Returns:
- the boolean
-
isGreaterThanOrEqualTo
public boolean isGreaterThanOrEqualTo(Quantity amount)
Is greater than or equal to boolean.- Specified by:
isGreaterThanOrEqualToin interfaceQuantity- Parameters:
amount- the amount- Returns:
- the boolean
-
isEqualTo
public boolean isEqualTo(Quantity amount)
Is equal to boolean.
-
isNotEqualTo
public boolean isNotEqualTo(Quantity amount)
Is not equal to boolean.- Parameters:
amount- the amount- Returns:
- the boolean
-
with
public RoundedAmount with(Operator operator)
With rounded unit.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(Quantity o)
Compare to int.- Specified by:
compareToin interfacejava.lang.Comparable<Quantity>- Parameters:
o- the o- Returns:
- the int
-
getNumber
public NumberValue getNumber()
Description copied from interface:QuantityGets the correspondingNumberValue.- Specified by:
getNumberin interfaceQuantity- Returns:
- the corresponding
NumberValue, not null.
-
multiply
public RoundedAmount multiply(long multiplicand)
Description copied from interface:QuantityReturns aQuantitywhose value is (this × multiplicand), and whose scale is
.this.scale() + multiplicand.scale()
-
multiply
public RoundedAmount multiply(double multiplicand)
Description copied from interface:QuantityReturns aQuantitywhose value is (this × multiplicand), and whose scale is
. By default the input value's scale will be rounded to accommodate the format capabilities, and nothis.scale() + multiplicand.scale()ArithmeticExceptionis thrown if the input number's scale exceeds the capabilities.
-
divide
public RoundedAmount divide(long divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is
, and whose preferred scale isthis / divisor
; if the exact quotient cannot be represented anthis.scale() - divisor.scale()ArithmeticExceptionis thrown.
-
divide
public RoundedAmount divide(double divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is
, and whose preferred scale isthis / divisor
; if the exact quotient cannot be represented anthis.scale() - divisor.scale()ArithmeticExceptionis thrown.
-
remainder
public RoundedAmount remainder(long divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is
. The remainder is given bythis % divisor
. Note that this is not the modulo operation (the result can be negative).this.subtract(this.divideToIntegralValue(divisor).multiply(divisor)
-
remainder
public RoundedAmount remainder(double divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is
. The remainder is given bythis % divisor
. Note that this is not the modulo operation (the result can be negative).this.subtract(this.divideToIntegralValue(divisor).multiply(divisor)
-
divideAndRemainder
public RoundedAmount[] divideAndRemainder(long divisor)
Description copied from interface:QuantityReturns a two-elementQuantityarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands. Note that if both the integer quotient and remainder are needed, this method is faster than using thedivideToIntegralValueandremaindermethods separately because the division need only be carried out once.- Specified by:
divideAndRemainderin interfaceQuantity- Parameters:
divisor- value by which thisQuantityis to be divided, and the remainder computed.- Returns:
- a two element
Quantityarray: the quotient (the result ofdivideToIntegralValue) is the initial element and the remainder is the final element. - See Also:
#divideToIntegralValue(long)#divideToIntegralValue(long)#divideToIntegralValue(long)#divideToIntegralValue(long)#divideToIntegralValue(long),#remainder(long)#remainder(long)#remainder(long)#remainder(long)#remainder(long)
-
divideAndRemainder
public RoundedAmount[] divideAndRemainder(double divisor)
Description copied from interface:QuantityReturns a two-elementQuantityarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands. Note that if both the integer quotient and remainder are needed, this method is faster than using thedivideToIntegralValueandremaindermethods separately because the division need only be carried out once.- Specified by:
divideAndRemainderin interfaceQuantity- Parameters:
divisor- value by which thisQuantityis to be divided, and the remainder computed.- Returns:
- a two element
Quantityarray: the quotient (the result ofdivideToIntegralValue) is the initial element and the remainder is the final element. - See Also:
#divideToIntegralValue(double)#divideToIntegralValue(double)#divideToIntegralValue(double)#divideToIntegralValue(double)#divideToIntegralValue(double),#remainder(double)#remainder(double)#remainder(double)#remainder(double)#remainder(double)
-
stripTrailingZeros
public RoundedAmount stripTrailingZeros()
Description copied from interface:QuantityReturns aQuantitywhich is numerically equal to this one but with any trailing zeros removed from the representation. For example, stripping the trailing zeros from theQuantityvalueUNIT 600.0, which has [BigInteger,scale] components equals to [6000, 1], yields6E2with [BigInteger,scale] components equals to [6, -2]- Specified by:
stripTrailingZerosin interfaceQuantity- Returns:
- a numerically equal
Quantitywith any trailing zeros removed.
-
divideToIntegralValue
public RoundedAmount divideToIntegralValue(long divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is the integer part of the quotient
rounded down. The preferred scale of the result isthis / divisor
.this.scale() - divisor.scale()- Specified by:
divideToIntegralValuein interfaceQuantity- Parameters:
divisor- value by which thisBigDecimalis to be divided.- Returns:
- The integer part of
this / divisor. - See Also:
java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)
-
divideToIntegralValue
public RoundedAmount divideToIntegralValue(double divisor)
Description copied from interface:QuantityReturns aQuantitywhose value is the integer part of the quotient
rounded down. The preferred scale of the result isthis / divisor
.this.scale() - divisor.scale()- Specified by:
divideToIntegralValuein interfaceQuantity- Parameters:
divisor- value by which thisBigDecimalis to be divided.- Returns:
- The integer part of
this / divisor. - See Also:
java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)java.math.BigDecimal#divideToIntegralValue(java.math.BigDecimal)
-
-