Show / Hide Table of Contents

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
Remarks

Currency is the wire model and keeps its value as text; this is the value to compute with. XrplAmountMath holds the ledger's arithmetic on it and XrplQuality the exchange rate of an offer.

A value is always canonical: every way of building one rounds it to what the asset can hold, as STAmount::canonicalize does.

Fields

| Edit this page View Source

MaxDrops

Largest amount of XRP, in drops (STAmount::kMaxNativeN).

Declaration
public const ulong MaxDrops = 100000000000000000
Field Value
Type Description
ulong
| Edit this page View Source

MaxIouExponent

Largest exponent of an issued-currency amount (STAmount::kMaxOffset).

Declaration
public const int MaxIouExponent = 80
Field Value
Type Description
int
| Edit this page View Source

MaxIouMantissa

Largest mantissa of an issued-currency amount (STAmount::kMaxValue).

Declaration
public const ulong MaxIouMantissa = 9999999999999999
Field Value
Type Description
ulong
| Edit this page View Source

MaxMptAmount

Largest amount of an MPT (kMaxMpTokenAmount).

Declaration
public const ulong MaxMptAmount = 9223372036854775807
Field Value
Type Description
ulong
| 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
Type Description
int
| 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
Type Description
ulong

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
Type Description
Common.IssuedCurrency
Remarks

null only for the unitless rates XrplQuality works with.

| 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
Type Description
bool
| Edit this page View Source

IsNegative

Whether the amount is below zero.

Declaration
public bool IsNegative { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsZero

Whether the amount is zero.

Declaration
public bool IsZero { get; }
Property Value
Type Description
bool
| Edit this page View Source

Kind

What the asset is, which decides how the amount rounds.

Declaration
public AmountKind Kind { get; }
Property Value
Type Description
AmountKind
| 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
Type Description
XrplNumber

Methods

| Edit this page View Source

AssetOf(Currency)

The asset a Currency is an amount of.

Declaration
public static Common.IssuedCurrency AssetOf(Currency currency)
Parameters
Type Name Description
Currency currency
Returns
Type Description
Common.IssuedCurrency
| Edit this page View Source

CompareTo(XrplAmount)

Compares two amounts of the same asset by value.

Declaration
public int CompareTo(XrplAmount other)
Parameters
Type Name Description
XrplAmount other
Returns
Type Description
int
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
Type Name Description
Currency currency
Returns
Type Description
XrplAmount
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
Type Name Description
Common.IssuedCurrency asset
XrplNumber value
NumberRounding rounding
Returns
Type Description
XrplAmount
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
Type Name Description
Common.IssuedCurrency asset
Returns
Type Description
AmountKind
| 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
Type Name Description
Common.IssuedCurrency asset
string value
Returns
Type Description
XrplAmount
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
Type Name Description
Common.IssuedCurrency a
Common.IssuedCurrency b
Returns
Type Description
bool
| 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
Type Description
Currency
| 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
Type Description
string
Overrides
System.ValueType.ToString()
| Edit this page View Source

TryParse(IssuedCurrency, string, out XrplAmount)

Parse(IssuedCurrency, string) that reports failure instead of throwing, for a malformed value or one beyond what the asset can hold.

Declaration
public static bool TryParse(Common.IssuedCurrency asset, string value, out XrplAmount amount)
Parameters
Type Name Description
Common.IssuedCurrency asset
string value
XrplAmount amount
Returns
Type Description
bool
| Edit this page View Source

Zero(IssuedCurrency)

A zero amount of the asset.

Declaration
public static XrplAmount Zero(Common.IssuedCurrency asset)
Parameters
Type Name Description
Common.IssuedCurrency asset
Returns
Type Description
XrplAmount

Operators

| Edit this page View Source

operator ==(XrplAmount, XrplAmount)

Declaration
public static bool operator ==(XrplAmount left, XrplAmount right)
Parameters
Type Name Description
XrplAmount left
XrplAmount right
Returns
Type Description
bool
| Edit this page View Source

operator >(XrplAmount, XrplAmount)

Declaration
public static bool operator >(XrplAmount left, XrplAmount right)
Parameters
Type Name Description
XrplAmount left
XrplAmount right
Returns
Type Description
bool
| Edit this page View Source

operator >=(XrplAmount, XrplAmount)

Declaration
public static bool operator >=(XrplAmount left, XrplAmount right)
Parameters
Type Name Description
XrplAmount left
XrplAmount right
Returns
Type Description
bool
| Edit this page View Source

operator !=(XrplAmount, XrplAmount)

Declaration
public static bool operator !=(XrplAmount left, XrplAmount right)
Parameters
Type Name Description
XrplAmount left
XrplAmount right
Returns
Type Description
bool
| Edit this page View Source

operator <(XrplAmount, XrplAmount)

Declaration
public static bool operator <(XrplAmount left, XrplAmount right)
Parameters
Type Name Description
XrplAmount left
XrplAmount right
Returns
Type Description
bool
| Edit this page View Source

operator <=(XrplAmount, XrplAmount)

Declaration
public static bool operator <=(XrplAmount left, XrplAmount right)
Parameters
Type Name Description
XrplAmount left
XrplAmount right
Returns
Type Description
bool
| Edit this page View Source

operator -(XrplAmount)

The same amount with the other sign.

Declaration
public static XrplAmount operator -(XrplAmount amount)
Parameters
Type Name Description
XrplAmount amount
Returns
Type Description
XrplAmount
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX