Input number. If this is a BigVal
instance then scale
and config
parameters will be ignored.
The scale of the input number. Default is min
.
Custom configuration for this instance.
Add another number to this one.
Divide this by another number.
Get whether this is equal to another number.
Get whether this is greater than another number.
Get whether this is greater than or equal to another number.
Get whether this is less than another number.
Get whether this is less than or equal to than another number.
Multiply with another number.
Subtract another number from this one.
Get config.
Get no. of decimal places in the curent value.
Get current scale.
Round to the nearest whole number.
Convert to 'coins' scale.
Get base-10 string representation to given no. of decimal places.
No. of decimal places to show.
Convert to 'min' scale.
Get base-10 number representation.
Convert to given scale.
Scale to convert to.
Get string representation in given base.
Base to represent in. Default is 10.
Construct a BigVal
instance.
Input number. If this is a BigVal
instance then scale
and config
parameters will be ignored.
The scale of the input number. Default is min
.
Custom configuration for this instance.
BigVal
instance.
Construct a BigVal
instance.
String in form: <number> <scale>
. If scale ommitted then min
is assumed.
Custom configuration for this instance.
BigVal
instance.
Generated using TypeDoc
Represents an arbitrarily large or small number with decimals.
All the arithmetic methods are immutable, i.e. they return a new
BigVal
instance, leaving the original inputs unchanged.At any given time a
BigVal
instance operates at a particular number scale. The scale is based on the the no. ofdecimals
specified in the configuration (BigValConfig
).The
min
scale is for numbers which do not have decimal places since they are already denominated in the smallest possible unit. Thecoins
scale is for numbers which implicitly have decimal places.For example, if a given
BigVal
hasdecimals = 2
then the following two numbers are equivalent in value:min
, value =100
coins
, value =1
If
decimals = 18
(this is the default) then the following two numbers are equivalent in value:min
, value =1000000000000000000
coins
, value = 1The use of scales like this makes it easy to convert between chain-friendly and user-friendly values and perform arithmetic at the desired precision.