dec
Call Signature
Section titled “Call Signature”dec():
Column<"dec",false,false,false>
Defined in: src/schema/values.ts:244
A dec column, indexed for equality and range queries once .indexed().
Returns
Section titled “Returns”Column<"dec", false, false, false>
Call Signature
Section titled “Call Signature”dec(
value):DecValue
Defined in: src/schema/values.ts:262
A signed fixed-point decimal with exactly 18 decimal places.
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 as a number