Class OceanusRatio
java.lang.Object
io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
io.github.tonywasher.joceanus.oceanus.decimal.OceanusRatio
- All Implemented Interfaces:
Comparable<OceanusDecimal>
Represents a Ratio object.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intStandard number of decimals for Ratio.static final OceanusRatioRatio of one.Fields inherited from class io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
BYTE_LEN, MAX_DECIMALS, RADIX_TEN -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor.OceanusRatio(byte[] pBuffer) Create the ratio from a byte array.OceanusRatio(OceanusDecimal pRatio) Construct a new Ratio by copying another ratio.OceanusRatio(OceanusDecimal pFirst, OceanusDecimal pSecond) Construct a new Ratio by the ratio between two decimals. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValue(OceanusDecimal pValue) Add a Decimal to the value.annualise(long pDays) Obtain annualised ratio.Obtain inverse ratio of this ratio (i.e. 1/this rate).static OceanusRatiogetWholeUnits(long pValue) Construct a new Units by setting the value explicitly.multiplyBy(OceanusRatio pRatio) Multiply by ratio.voidsubtractValue(OceanusDecimal pValue) Subtract a Decimal from the value.Methods inherited from class io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
add, adjustDecimals, adjustToScale, byteValue, byteValueExact, calculateProduct, calculateQuotient, calculateSafeQuotient, checkFractionalZero, compareTo, divide, divide, divideToIntegralValue, doubleValue, equals, floatValue, getFactor, hashCode, intValue, intValueExact, isNonZero, isPositive, isZero, longValue, longValueExact, max, min, movePointLeft, movePointRight, multiply, multiply, negate, recordScale, reduceScale, remainder, scale, setValue, setZero, shortValue, shortValueExact, signum, subtract, toBigDecimal, toBigInteger, toBigIntegerExact, toBytes, toString, unscaledValue
-
Field Details
-
NUM_DECIMALS
protected static final int NUM_DECIMALSStandard number of decimals for Ratio.- See Also:
-
ONE
Ratio of one.
-
-
Constructor Details
-
OceanusRatio
protected OceanusRatio()Constructor. -
OceanusRatio
Construct a new Ratio by copying another ratio.- Parameters:
pRatio- the Ratio to copy
-
OceanusRatio
Construct a new Ratio by the ratio between two decimals.- Parameters:
pFirst- the first decimalpSecond- the second decimal
-
OceanusRatio
public OceanusRatio(byte[] pBuffer) Create the ratio from a byte array.- Parameters:
pBuffer- the buffer
-
-
Method Details
-
getWholeUnits
Construct a new Units by setting the value explicitly.- Parameters:
pValue- the unscaled value- Returns:
- the new Rate
-
getInverseRatio
Obtain inverse ratio of this ratio (i.e. 1/this rate).- Returns:
- the inverse ratio
-
multiplyBy
Multiply by ratio.- Parameters:
pRatio- the multiplying ratio- Returns:
- the new ratio
-
annualise
Obtain annualised ratio.- Parameters:
pDays- the number of days in the period- Returns:
- the annualised ratio
-
addValue
Description copied from class:OceanusDecimalAdd a Decimal to the value. The value of this Decimal is updated and the scale is maintained.- Overrides:
addValuein classOceanusDecimal- Parameters:
pValue- The Decimal to add to this one.
-
subtractValue
Description copied from class:OceanusDecimalSubtract a Decimal from the value. The value of this Decimal is updated and the scale is maintained.- Overrides:
subtractValuein classOceanusDecimal- Parameters:
pValue- The decimal to subtract from this one.
-