dec
dec(
value):DecValue
Defined in: src/attr/values.ts:226
A signed fixed-point decimal with exactly 18 decimal places, indexed for equality and range queries.
Pass fractional values as strings. A JavaScript number cannot represent most decimals
exactly, so accepting dec(0.1 + 0.2) would quietly store 0.30000000000000004; requiring the
string keeps what you write and what is stored the same thing. Excess precision is likewise an
error rather than a rounding.
Parameters
Section titled “Parameters”A decimal string, or an integral number / bigint.
string | number | bigint
Returns
Section titled “Returns”Throws
Section titled “Throws”If the value is malformed, has more than 18 fractional digits, or
falls outside the int256 range.
Example
Section titled “Example”dec("3.5")dec("-0.000000000000000001") // the smallest stepdec(5) // integers may be passed bare