Constructs a value object instance for calculations. The initial value is 0;
The number of decimals of the amount. Must be between 0 and 8
Adds another value to this value
The other value to be added
the mutated value object
Clones/Copies the current ChainValue to a new object
new ChainValue instance
Divides this value object with a numeric value (not ChainValue!)
A numeric value to be divided by
the mutated value object
Checks for equality
The other value to be compared
true if equal, otherwise false
Gets Atomic representation
Gets the 'compound' representation
value in decimal related representation, i.e. 100 QNT with 3 decimals results in '0.3'
The set decimals amount
Leaky value getter
the underlying value in its big number representation (immutable)
Checks for greater value
The other value to be compared
true if greater, otherwise false
Checks for greater or equality value
The other value to be compared
true if greater or equal, otherwise false
Checks for lesser value
The other value to be compared
true if less, otherwise false
Checks for lesser or equality
The other value to be compared
true if less or equal, otherwise false
Multiplies this value object with a numeric value (not ChainValue!)
A numeric value to be multiplied with
the mutated value object
Sets value as atomic value, i.e. overwrites current hold value
The atomic value. Float numbers are floored to first lower integer, i.e. 1.23
-> 1
the updated value object
Sets as 'compound' representation
compound value
the updated value object
Subtracts another value from this value
The other value to be subtracted
the mutated value object
Gets a string representation according to ChainValueFormat
The prefix for value
The format object, Default: ChainValueFormats.DotDecimal
The formatted string
Constructs a value object instance for calculations. The initial value is 0;
The number of decimals of the amount. Must be between 0 and 8
A Value Object to facilitate calculations for token and coin values (QNT/NQT).
For efficiency reasons, the monetary values/quantities are stored as integers with a prefined set of decimals, e.g. Signa has 8 decimals and stores the values as Planck that is 1 Signa = 100_000_000 Planck (NQT) and tokens have configurable decimals (0 to 8), so that a custom FooCoin can hav 2 decimals only where 1 FOO = 100 FOOQNT
In this context integer quantities are denominates as _atomic values and fractional values considering the decimals are denominated as compound values.
Note: This class uses a big number representation (ES5 compatible) under the hood, so number limits and numeric calculations are much more precise than JS number type