java.lang.Object
io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
io.github.tonywasher.joceanus.oceanus.decimal.OceanusRatio
All Implemented Interfaces:
Comparable<OceanusDecimal>

public class OceanusRatio extends OceanusDecimal
Represents a Ratio object.
  • Field Details

    • NUM_DECIMALS

      protected static final int NUM_DECIMALS
      Standard number of decimals for Ratio.
      See Also:
    • ONE

      public static final OceanusRatio ONE
      Ratio of one.
  • Constructor Details

    • OceanusRatio

      protected OceanusRatio()
      Constructor.
    • OceanusRatio

      public OceanusRatio(OceanusRatio pRatio)
      Construct a new Ratio by copying another ratio.
      Parameters:
      pRatio - the Ratio to copy
    • OceanusRatio

      public OceanusRatio(String pSource)
      Constructor for ratio from a decimal string.
      Parameters:
      pSource - The source decimal string
      Throws:
      IllegalArgumentException - on invalidly formatted argument
    • OceanusRatio

      public OceanusRatio(OceanusDecimal pFirst, OceanusDecimal pSecond)
      Construct a new Ratio by the ratio between two decimals.
      Parameters:
      pFirst - the first decimal
      pSecond - the second decimal
    • OceanusRatio

      public OceanusRatio(byte[] pBuffer)
      Create the ratio from a byte array.
      Parameters:
      pBuffer - the buffer
  • Method Details

    • getInverseRatio

      public OceanusRatio getInverseRatio()
      Obtain inverse ratio of this ratio (i.e. 100%/this rate).
      Returns:
      the inverse ratio
    • multiplyBy

      public OceanusRatio multiplyBy(OceanusRatio pRatio)
      Multiply by ratio.
      Parameters:
      pRatio - the multiplying ratio
      Returns:
      the new ratio
    • annualise

      public OceanusRate annualise(long pDays)
      Obtain annualised ratio.
      Parameters:
      pDays - the number of days in the period
      Returns:
      the annualised ratio
    • addValue

      public void addValue(OceanusDecimal pValue)
      Description copied from class: OceanusDecimal
      Add a Decimal to the value. The value of this Decimal is updated and the scale is maintained.
      Overrides:
      addValue in class OceanusDecimal
      Parameters:
      pValue - The Decimal to add to this one.
    • subtractValue

      public void subtractValue(OceanusDecimal pValue)
      Description copied from class: OceanusDecimal
      Subtract a Decimal from the value. The value of this Decimal is updated and the scale is maintained.
      Overrides:
      subtractValue in class OceanusDecimal
      Parameters:
      pValue - The decimal to subtract from this one.