Class XrplAmountMath
rippled's STAmount arithmetic on XrplAmount, bit for bit: addition,
multiply, divide, and the directed rounding mulRound / divRound
that offer crossing uses, in both their legacy and strict forms.
Inheritance
object
XrplAmountMath
Namespace: Xrpl.Amounts
Assembly: Xrpl.dll
Syntax
public static class XrplAmountMath
Methods
|
Edit this page
View Source
Add(XrplAmount, XrplAmount, LedgerRules)
Declaration
public static XrplAmount Add(XrplAmount a, XrplAmount b, LedgerRules rules = null)
Parameters
Returns
Exceptions
| Type |
Condition |
| ArgumentException |
The amounts are of different assets.
|
| OverflowException |
The sum is beyond what the asset can hold.
|
|
Edit this page
View Source
DivRound(XrplAmount, XrplAmount, IssuedCurrency, bool, LedgerRules)
divRound: the quotient as an amount of asset, away from zero when
roundUp, otherwise toward zero - with the legacy rounding described on
the class.
Declaration
public static XrplAmount DivRound(XrplAmount num, XrplAmount den, Common.IssuedCurrency asset, bool roundUp, LedgerRules rules = null)
Parameters
Returns
Exceptions
| Type |
Condition |
| DivideByZeroException |
den is zero.
|
|
Edit this page
View Source
DivRoundStrict(XrplAmount, XrplAmount, IssuedCurrency, bool, LedgerRules)
Declaration
public static XrplAmount DivRoundStrict(XrplAmount num, XrplAmount den, Common.IssuedCurrency asset, bool roundUp, LedgerRules rules = null)
Parameters
Returns
Exceptions
| Type |
Condition |
| DivideByZeroException |
den is zero.
|
|
Edit this page
View Source
Divide(XrplAmount, XrplAmount, IssuedCurrency, LedgerRules)
divide(num, den, asset): both mantissas scaled to at least 10^15,
num * 10^17 / den truncated, plus 5, as an amount of asset.
Declaration
public static XrplAmount Divide(XrplAmount num, XrplAmount den, Common.IssuedCurrency asset, LedgerRules rules = null)
Parameters
Returns
Exceptions
| Type |
Condition |
| DivideByZeroException |
den is zero.
|
| OverflowException |
The quotient is beyond what the asset can hold.
|
|
Edit this page
View Source
MulRound(XrplAmount, XrplAmount, IssuedCurrency, bool, LedgerRules)
mulRound: the product as an amount of asset, away from zero when
roundUp, otherwise toward zero - with the legacy rounding described on
the class.
Declaration
public static XrplAmount MulRound(XrplAmount v1, XrplAmount v2, Common.IssuedCurrency asset, bool roundUp, LedgerRules rules = null)
Parameters
Returns
|
Edit this page
View Source
MulRoundStrict(XrplAmount, XrplAmount, IssuedCurrency, bool, LedgerRules)
Declaration
public static XrplAmount MulRoundStrict(XrplAmount v1, XrplAmount v2, Common.IssuedCurrency asset, bool roundUp, LedgerRules rules = null)
Parameters
Returns
|
Edit this page
View Source
Multiply(XrplAmount, XrplAmount, IssuedCurrency, LedgerRules)
multiply(v1, v2, asset): the product as an amount of asset,
exact for XRP x XRP and MPT x MPT, otherwise through Number.
Declaration
public static XrplAmount Multiply(XrplAmount v1, XrplAmount v2, Common.IssuedCurrency asset, LedgerRules rules = null)
Parameters
Returns
Exceptions
| Type |
Condition |
| OverflowException |
The product is beyond what the asset can hold.
|
|
Edit this page
View Source
Multiply(XrplAmount, XrplNumber, NumberRounding, LedgerRules)
multiply(amount, frac, rm): the product computed in rounding,
then made an amount of the asset in the same mode (toSTAmount).
Declaration
public static XrplAmount Multiply(XrplAmount amount, XrplNumber fraction, NumberRounding rounding, LedgerRules rules = null)
Parameters
Returns
|
Edit this page
View Source
Subtract(XrplAmount, XrplAmount, LedgerRules)
Declaration
public static XrplAmount Subtract(XrplAmount a, XrplAmount b, LedgerRules rules = null)
Parameters
Returns
Exceptions
| Type |
Condition |
| ArgumentException |
The amounts are of different assets.
|
| OverflowException |
The difference is beyond what the asset can hold.
|