Struct XrplAmount
An amount of one asset, held the way rippled's STAmount holds it: XRP as a whole
number of drops, an MPT as a whole number of units, an issued currency as a 16-digit
mantissa with an exponent from -96 to 80. The whole range of the ledger is representable.
Namespace: Xrpl.Amounts
Assembly: Xrpl.dll
Syntax
public readonly struct XrplAmount
Fields
|
Edit this page
View Source
MaxDrops
Largest amount of XRP, in drops (STAmount::kMaxNativeN).
Declaration
public const ulong MaxDrops = 100000000000000000
Field Value
|
Edit this page
View Source
MaxIouExponent
Largest exponent of an issued-currency amount (STAmount::kMaxOffset).
Declaration
public const int MaxIouExponent = 80
Field Value
|
Edit this page
View Source
MaxIouMantissa
Largest mantissa of an issued-currency amount (STAmount::kMaxValue).
Declaration
public const ulong MaxIouMantissa = 9999999999999999
Field Value
|
Edit this page
View Source
MaxMptAmount
Largest amount of an MPT (kMaxMpTokenAmount).
Declaration
public const ulong MaxMptAmount = 9223372036854775807
Field Value
|
Edit this page
View Source
MinIouExponent
Smallest exponent of a non-zero issued-currency amount (STAmount::kMinOffset).
Declaration
public const int MinIouExponent = -96
Field Value
|
Edit this page
View Source
MinIouMantissa
Smallest mantissa of a non-zero issued-currency amount (STAmount::kMinValue).
Declaration
public const ulong MinIouMantissa = 1000000000000000
Field Value
Properties
|
Edit this page
View Source
Asset
The asset: XRP, a currency with its issuer, or an MPT issuance.
Declaration
public Common.IssuedCurrency Asset { get; }
Property Value
|
Edit this page
View Source
IsIntegral
Whether the amount is XRP or an MPT, which hold whole units only.
Declaration
public bool IsIntegral { get; }
Property Value
|
Edit this page
View Source
IsNegative
Whether the amount is below zero.
Declaration
public bool IsNegative { get; }
Property Value
|
Edit this page
View Source
IsZero
Whether the amount is zero.
Declaration
public bool IsZero { get; }
Property Value
|
Edit this page
View Source
Kind
What the asset is, which decides how the amount rounds.
Declaration
public AmountKind Kind { get; }
Property Value
|
Edit this page
View Source
Value
The value: drops for XRP, units for an MPT, the currency's own unit for an issued
currency.
Declaration
public XrplNumber Value { get; }
Property Value
Methods
|
Edit this page
View Source
AssetOf(Currency)
Declaration
public static Common.IssuedCurrency AssetOf(Currency currency)
Parameters
Returns
|
Edit this page
View Source
CompareTo(XrplAmount)
Compares two amounts of the same asset by value.
Declaration
public int CompareTo(XrplAmount other)
Parameters
Returns
Exceptions
| Type |
Condition |
| ArgumentException |
The amounts are of different assets.
|
|
Edit this page
View Source
Equals(object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object obj)
Parameters
| Type |
Name |
Description |
| object |
obj |
The object to compare with the current instance.
|
Returns
| Type |
Description |
| bool |
true if obj and this instance are the same type and represent the same value; otherwise, false.
|
Overrides
System.ValueType.Equals(object)
|
Edit this page
View Source
Equals(XrplAmount)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(XrplAmount other)
Parameters
| Type |
Name |
Description |
| XrplAmount |
other |
An object to compare with this object.
|
Returns
| Type |
Description |
| bool |
true if the current object is equal to the other parameter; otherwise, false.
|
|
Edit this page
View Source
FromCurrency(Currency)
The amount a Currency carries, read over the ledger's whole range.
Declaration
public static XrplAmount FromCurrency(Currency currency)
Parameters
Returns
Exceptions
| Type |
Condition |
| FormatException |
The value is not an amount.
|
| OverflowException |
The value is beyond what the asset can hold.
|
|
Edit this page
View Source
FromNumber(IssuedCurrency, XrplNumber, NumberRounding)
STAmount{asset, value} (STAmount::fromNumber): the magnitude rounded to what
the asset holds - a whole drop or unit for XRP and MPT, 16 significant digits for an
issued currency - in rounding, and the sign put back. A directed mode
therefore applies to the magnitude: Upward rounds away
from zero.
Declaration
public static XrplAmount FromNumber(Common.IssuedCurrency asset, XrplNumber value, NumberRounding rounding = NumberRounding.ToNearest)
Parameters
Returns
Exceptions
| Type |
Condition |
| OverflowException |
The value is beyond what the asset can hold.
|
|
Edit this page
View Source
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type |
Description |
| int |
A 32-bit signed integer that is the hash code for this instance.
|
Overrides
System.ValueType.GetHashCode()
|
Edit this page
View Source
KindOf(IssuedCurrency)
Which AmountKind an asset is. No asset at all is the unitless rate rippled
calls noIssue(), which rounds like an issued currency.
Declaration
public static AmountKind KindOf(Common.IssuedCurrency asset)
Parameters
Returns
|
Edit this page
View Source
Parse(IssuedCurrency, string)
Reads an amount the way rippled's amountFromString does: XRP in drops, an MPT in
units, an issued currency in decimal or scientific notation, rounded to nearest.
Declaration
public static XrplAmount Parse(Common.IssuedCurrency asset, string value)
Parameters
Returns
Exceptions
| Type |
Condition |
| FormatException |
The text is not a number, or XRP or an MPT with a fraction.
|
| OverflowException |
The value is beyond what the asset can hold.
|
|
Edit this page
View Source
SameAsset(IssuedCurrency, IssuedCurrency)
Whether two assets are the same asset.
Declaration
public static bool SameAsset(Common.IssuedCurrency a, Common.IssuedCurrency b)
Parameters
Returns
|
Edit this page
View Source
ToCurrency()
The amount as the wire model, its value written the way rippled writes it.
Declaration
public Currency ToCurrency()
Returns
|
Edit this page
View Source
ToString()
STAmount::getText: drops and MPT units as an integer; an issued currency in plain
decimal, or in scientific notation when its exponent is below -25 or above -5.
Declaration
public override string ToString()
Returns
Overrides
System.ValueType.ToString()
|
Edit this page
View Source
TryParse(IssuedCurrency, string, out XrplAmount)
Declaration
public static bool TryParse(Common.IssuedCurrency asset, string value, out XrplAmount amount)
Parameters
Returns
|
Edit this page
View Source
Zero(IssuedCurrency)
A zero amount of the asset.
Declaration
public static XrplAmount Zero(Common.IssuedCurrency asset)
Parameters
Returns
Operators
|
Edit this page
View Source
operator ==(XrplAmount, XrplAmount)
Declaration
public static bool operator ==(XrplAmount left, XrplAmount right)
Parameters
Returns
|
Edit this page
View Source
operator >(XrplAmount, XrplAmount)
Declaration
public static bool operator >(XrplAmount left, XrplAmount right)
Parameters
Returns
|
Edit this page
View Source
operator >=(XrplAmount, XrplAmount)
Declaration
public static bool operator >=(XrplAmount left, XrplAmount right)
Parameters
Returns
|
Edit this page
View Source
operator !=(XrplAmount, XrplAmount)
Declaration
public static bool operator !=(XrplAmount left, XrplAmount right)
Parameters
Returns
|
Edit this page
View Source
operator <(XrplAmount, XrplAmount)
Declaration
public static bool operator <(XrplAmount left, XrplAmount right)
Parameters
Returns
|
Edit this page
View Source
operator <=(XrplAmount, XrplAmount)
Declaration
public static bool operator <=(XrplAmount left, XrplAmount right)
Parameters
Returns
|
Edit this page
View Source
operator -(XrplAmount)
The same amount with the other sign.
Declaration
public static XrplAmount operator -(XrplAmount amount)
Parameters
Returns