Struct FungibleAssetValue
Holds a fungible asset value which holds its Currency together.
Implements
Inherited Members
Namespace: Libplanet.Types.Assets
Assembly: Libplanet.Types.dll
Syntax
[JsonConverter(typeof(FungibleAssetValueJsonConverter))]
[Serializable]
public readonly struct FungibleAssetValue : IEquatable<FungibleAssetValue>, IComparable<FungibleAssetValue>, IComparable, ISerializable
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Constructors
| Improve this Doc View SourceFungibleAssetValue(IValue)
Holds a fungible asset value which holds its Currency together.
Declaration
public FungibleAssetValue(IValue value)
Parameters
Type | Name | Description |
---|---|---|
Bencodex.Types.IValue | value |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
FungibleAssetValue(Currency, Int32, BigInteger, BigInteger)
Creates a value of the currency
from the given sign
, majorUnit
and minorUnit
.
Declaration
public FungibleAssetValue(Currency currency, int sign, BigInteger majorUnit, BigInteger minorUnit)
Parameters
Type | Name | Description |
---|---|---|
Currency | currency | The currency to create a value. |
Int32 | sign | Indicates the sign (negative, positive, or zero) of the value.
|
BigInteger | majorUnit | The major unit of the fungible asset value, i.e., digits before the decimal separator. Must not be negative. |
BigInteger | minorUnit | The minor unit of the fungible asset value, i.e., digits after the decimal separator. Must not be negative. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when the the |
See Also
| Improve this Doc View SourceFungibleAssetValue(Currency, BigInteger, BigInteger)
Creates a value of the currency
from the given
majorUnit
and minorUnit
.
Declaration
public FungibleAssetValue(Currency currency, BigInteger majorUnit, BigInteger minorUnit)
Parameters
Type | Name | Description |
---|---|---|
Currency | currency | The currency to create a value. |
BigInteger | majorUnit | The major unit of the fungible asset value, i.e., digits before the decimal separator. |
BigInteger | minorUnit | The minor unit of the fungible asset value, i.e., digits after the decimal separator. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when the negativity sign is ambiguous
(e.g., both units have signs) or too big for the |
See Also
| Improve this Doc View SourceFungibleAssetValue(Currency)
Creates a zero value of the currency
.
Declaration
public FungibleAssetValue(Currency currency)
Parameters
Type | Name | Description |
---|---|---|
Currency | currency | The currency to create a zero value. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Fields
| Improve this Doc View SourceCurrency
The currency of the fungible asset.
Declaration
public readonly Currency Currency
Field Value
Type | Description |
---|---|
Currency |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
RawValue
The internal representation of the fungible asset.
Declaration
public readonly BigInteger RawValue
Field Value
Type | Description |
---|---|
BigInteger |
Remarks
Since this is an internal representation, this does not guarantee forward compatibility. Therefore, do not depend on this value for permanent uses but only for volatile data.
See Also
Properties
| Improve this Doc View SourceMajorUnit
The major unit of the fungible asset value, i.e., digits before the decimal separator, in absolute value.
Declaration
[Pure]
public readonly BigInteger MajorUnit { get; }
Property Value
Type | Description |
---|---|
BigInteger |
Remarks
It is absolute value, which lacks Sign.
See Also
| Improve this Doc View SourceMinorUnit
The minor unit of the fungible asset value, i.e., digits after the decimal separator, in absolute value.
Declaration
[Pure]
public readonly BigInteger MinorUnit { get; }
Property Value
Type | Description |
---|---|
BigInteger |
Remarks
It is absolute value, which lacks Sign.
See Also
| Improve this Doc View SourceSign
Gets a number that indicates the sign (negative, positive, or zero) of the value.
Declaration
[Pure]
public readonly int Sign { get; }
Property Value
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
Int32 | A number that indicates the sign of the fungible asset value, as shown in the following table:
|
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Methods
| Improve this Doc View SourceAbs()
Gets the absolute value.
Removes the negative sign if it's negative. Otherwise does nothing.
Declaration
[Pure]
public readonly FungibleAssetValue Abs()
Returns
Type | Description |
---|---|
FungibleAssetValue | Its absolute value. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
CompareTo(FungibleAssetValue)
Holds a fungible asset value which holds its Currency together.
Declaration
[Pure]
public readonly int CompareTo(FungibleAssetValue other)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | other |
Returns
Type | Description |
---|---|
Int32 |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
CompareTo(Object)
Holds a fungible asset value which holds its Currency together.
Declaration
[Pure]
public readonly int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Int32 |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
DivRem(FungibleAssetValue, out FungibleAssetValue)
Divides the value by divisor
, returns the quotient, and returns
the remainder
in an output parameter.
Declaration
[Pure]
public readonly BigInteger DivRem(FungibleAssetValue divisor, out FungibleAssetValue remainder)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | divisor | The value to divide by. |
FungibleAssetValue | remainder | When this method returns (without any exception), the remainder
after dividing the value by |
Returns
Type | Description |
---|---|
BigInteger | The quotient of the division. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when two values do not have the same Currency. |
DivideByZeroException | Thrown when the |
DivRem(FungibleAssetValue)
Divides the value by divisor
, and returns a pair of the quotient
and the remainder.
Declaration
[Pure]
public readonly (BigInteger Quotient, FungibleAssetValue Remainder) DivRem(FungibleAssetValue divisor)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | divisor | The value to divide by. |
Returns
Type | Description |
---|---|
(T1 Item1, T2 Item2)<BigInteger, FungibleAssetValue> | A tuple of the |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when two values do not have the same Currency. |
DivideByZeroException | Thrown when the |
DivRem(BigInteger, out FungibleAssetValue)
Divides the value by divisor
, returns the quotient, and returns
the remainder
in an output parameter.
Declaration
[Pure]
public readonly FungibleAssetValue DivRem(BigInteger divisor, out FungibleAssetValue remainder)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | divisor | The number to divide by. |
FungibleAssetValue | remainder | When this method returns (without any exception), the remainder
after dividing the value by |
Returns
Type | Description |
---|---|
FungibleAssetValue | The quotient of the division. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
DivideByZeroException | Thrown when the |
DivRem(BigInteger)
Divides the value by divisor
, and returns a pair of the quotient
and the remainder.
Declaration
[Pure]
public readonly (FungibleAssetValue Quotient, FungibleAssetValue Remainder) DivRem(BigInteger divisor)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | divisor | The number to divide by. |
Returns
Type | Description |
---|---|
(T1 Item1, T2 Item2)<FungibleAssetValue, FungibleAssetValue> | A tuple of the |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
DivideByZeroException | Thrown when the |
Equals(FungibleAssetValue)
Holds a fungible asset value which holds its Currency together.
Declaration
[Pure]
public readonly bool Equals(FungibleAssetValue other)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | other |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Equals(Object)
Holds a fungible asset value which holds its Currency together.
Declaration
[Pure]
public override readonly bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
FromRawValue(Currency, BigInteger)
Restores a value from a rawValue
of a currency
.
Declaration
public static FungibleAssetValue FromRawValue(Currency currency, BigInteger rawValue)
Parameters
Type | Name | Description |
---|---|---|
Currency | currency | The currency to create a value. |
BigInteger | rawValue | The RawValue to restore. |
Returns
Type | Description |
---|---|
FungibleAssetValue | The value restored from the given |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
See Also
| Improve this Doc View SourceGetHashCode()
Holds a fungible asset value which holds its Currency together.
Declaration
[Pure]
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
GetQuantityString(Boolean)
Declaration
[Pure]
public readonly string GetQuantityString(bool minorUnit = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | minorUnit | Whether to show all possible decimal places even if they are zeros. |
Returns
Type | Description |
---|---|
String | A quantity string in decimal system. Consists of an optional sign (minus), digits and an optional decimal separator (period). |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Parse(Currency, String)
Parses a numeric string and returns a corresponding FungibleAssetValue.
Declaration
public static FungibleAssetValue Parse(Currency currency, string value)
Parameters
Type | Name | Description |
---|---|---|
Currency | currency | The currency of the value to parse. |
String | value | A numeric string to parse. Can consist of digits, plus (+), minus (-), and decimal separator (.). |
Returns
Type | Description |
---|---|
FungibleAssetValue | The parsed asset value. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
FormatException | Thrown when the given |
Serialize()
Holds a fungible asset value which holds its Currency together.
Declaration
public readonly IValue Serialize()
Returns
Type | Description |
---|---|
Bencodex.Types.IValue |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
ToString()
Holds a fungible asset value which holds its Currency together.
Declaration
[Pure]
public override readonly string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Operators
| Improve this Doc View SourceAddition(FungibleAssetValue, FungibleAssetValue)
Adds two values and returns the result.
Declaration
[Pure]
public static FungibleAssetValue operator +(FungibleAssetValue left, FungibleAssetValue right)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | left | The first value to add. |
FungibleAssetValue | right | The second value to add. |
Returns
Type | Description |
---|---|
FungibleAssetValue | The sum of |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when two values do not have the same Currency. |
Equality(FungibleAssetValue, FungibleAssetValue)
Tests if two values are equal.
Declaration
[Pure]
public static bool operator ==(FungibleAssetValue obj, FungibleAssetValue other)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | obj | A value. |
FungibleAssetValue | other | Another value. |
Returns
Type | Description |
---|---|
System.Boolean | true if two values are equal. Otherwise false. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
GreaterThan(FungibleAssetValue, FungibleAssetValue)
Tests if the left operand (obj
) is greater than the right operand
(other
).
Declaration
[Pure]
public static bool operator>(FungibleAssetValue obj, FungibleAssetValue other)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | obj | The left operand to compare. |
FungibleAssetValue | other | The right operand to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true
if the left operand ( |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
GreaterThanOrEqual(FungibleAssetValue, FungibleAssetValue)
Tests if the left operand (obj
) is greater than or equal to the right
operand (other
).
Declaration
[Pure]
public static bool operator >=(FungibleAssetValue obj, FungibleAssetValue other)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | obj | The left operand to compare. |
FungibleAssetValue | other | The right operand to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true
if the left operand ( |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Inequality(FungibleAssetValue, FungibleAssetValue)
Tests if two values are unequal.
Declaration
[Pure]
public static bool operator !=(FungibleAssetValue obj, FungibleAssetValue other)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | obj | A value. |
FungibleAssetValue | other | Another value. |
Returns
Type | Description |
---|---|
System.Boolean | false if two values are equal. Otherwise true. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
LessThan(FungibleAssetValue, FungibleAssetValue)
Tests if the left operand (obj
) is less than the right operand
(other
).
Declaration
[Pure]
public static bool operator <(FungibleAssetValue obj, FungibleAssetValue other)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | obj | The left operand to compare. |
FungibleAssetValue | other | The right operand to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true
if the left operand ( |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
LessThanOrEqual(FungibleAssetValue, FungibleAssetValue)
Tests if the left operand (obj
) is less than or equal to the right
operand (other
).
Declaration
[Pure]
public static bool operator <=(FungibleAssetValue obj, FungibleAssetValue other)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | obj | The left operand to compare. |
FungibleAssetValue | other | The right operand to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true
if the left operand ( |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Modulus(FungibleAssetValue, FungibleAssetValue)
Divides the value (dividend
) by divisor
,
and returns the remainder.
Declaration
[Pure]
public static FungibleAssetValue operator %(FungibleAssetValue dividend, FungibleAssetValue divisor)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | dividend | The value to be divided. |
FungibleAssetValue | divisor | The value to divide by. |
Returns
Type | Description |
---|---|
FungibleAssetValue | The remainder after dividing |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when two values do not have the same Currency. |
DivideByZeroException | Thrown when the |
Modulus(FungibleAssetValue, BigInteger)
Divides the value (dividend
) by divisor
,
and returns the remainder.
Declaration
[Pure]
public static FungibleAssetValue operator %(FungibleAssetValue dividend, BigInteger divisor)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | dividend | The value to be divided. |
BigInteger | divisor | The number to divide by. |
Returns
Type | Description |
---|---|
FungibleAssetValue | The remainder after dividing |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
DivideByZeroException | Thrown when the |
Multiply(FungibleAssetValue, BigInteger)
Multiplies right
times the left
value.
Declaration
[Pure]
public static FungibleAssetValue operator *(FungibleAssetValue left, BigInteger right)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | left | The value to multiply. |
BigInteger | right | The times to multiply. |
Returns
Type | Description |
---|---|
FungibleAssetValue | The multiplied value. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Multiply(BigInteger, FungibleAssetValue)
Multiplies left
times the right
value.
Declaration
[Pure]
public static FungibleAssetValue operator *(BigInteger left, FungibleAssetValue right)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | left | The times to multiply. |
FungibleAssetValue | right | The value to multiply. |
Returns
Type | Description |
---|---|
FungibleAssetValue | The multiplied value. |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Subtraction(FungibleAssetValue, FungibleAssetValue)
Subtracts the right
value from the left
value.
Declaration
[Pure]
public static FungibleAssetValue operator -(FungibleAssetValue left, FungibleAssetValue right)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | left | The value to subtract from (the minuend). |
FungibleAssetValue | right | The value to subtract (the subtrahend). |
Returns
Type | Description |
---|---|
FungibleAssetValue | The result of subtracting |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when two values do not have the same Currency. |
UnaryNegation(FungibleAssetValue)
Negates a value
.
Adds a negative sign to the value
if it's positive.
Removes a negative sign from the value
if it's already negative.
Does nothing if the value
is zero.
Declaration
[Pure]
public static FungibleAssetValue operator -(FungibleAssetValue value)
Parameters
Type | Name | Description |
---|---|---|
FungibleAssetValue | value | A value to negate. |
Returns
Type | Description |
---|---|
FungibleAssetValue | A negated |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.
Explicit Interface Implementations
| Improve this Doc View SourceISerializable.GetObjectData(SerializationInfo, StreamingContext)
Holds a fungible asset value which holds its Currency together.
Declaration
readonly void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | |
StreamingContext | context |
Remarks
It behaves like numbers except for division operator (/
) to prevent to forget
to handle its remainder; use DivRem(FungibleAssetValue) and DivRem(BigInteger) methods instead.