Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents decimal values serialized with 18 digits of precision. This implementation is based on the decimal.js library, and returns Dec values for only Dec.add, Dec.sub, Dec.mul, Dec.div, and Dec.mod. For other methods inherited from Decimal, you will need to convert back to Dec to remain compatible for submitting information that requires Dec format back to the blockchain.

Example:

const dec = new Dec(1.5);

const decimal = dec.sqrt();
const dec2 = new Dec(decimal);

Hierarchy

  • Decimal
    • Dec

Implements

Index

Type aliases

Static Constructor

Constructor: typeof Decimal

Static Instance

Instance: Decimal

Static Modulo

Modulo: Rounding | 9

Static Rounding

Rounding: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8

Static Value

Value: string | number | Decimal

Constructors

constructor

Properties

Readonly d

d: number[]

Readonly e

e: number

Readonly s

s: number

Static Optional Readonly Decimal

Decimal: Decimal.Constructor

Static Readonly EUCLID

EUCLID: 9

Static Readonly ROUND_CEIL

ROUND_CEIL: 2

Static Readonly ROUND_DOWN

ROUND_DOWN: 1

Static Readonly ROUND_FLOOR

ROUND_FLOOR: 3

Static Readonly ROUND_HALF_CEIL

ROUND_HALF_CEIL: 7

Static Readonly ROUND_HALF_DOWN

ROUND_HALF_DOWN: 5

Static Readonly ROUND_HALF_EVEN

ROUND_HALF_EVEN: 6

Static Readonly ROUND_HALF_FLOOR

ROUND_HALF_FLOOR: 8

Static Readonly ROUND_HALF_UP

ROUND_HALF_UP: 4

Static Readonly ROUND_UP

ROUND_UP: 0

Static Readonly crypto

crypto: boolean

Static Optional Readonly default

default: Decimal.Constructor

Static Readonly maxE

maxE: number

Static Readonly minE

minE: number

Static Readonly modulo

modulo: Decimal.Modulo

Static Readonly precision

precision: number

Static Readonly rounding

rounding: Decimal.Rounding

Static Readonly toExpNeg

toExpNeg: number

Static Readonly toExpPos

toExpPos: number

Methods

abs

  • abs(): Decimal
  • Returns Decimal

absoluteValue

  • absoluteValue(): Decimal
  • Returns Decimal

acos

  • acos(): Decimal
  • Returns Decimal

acosh

  • acosh(): Decimal
  • Returns Decimal

add

asin

  • asin(): Decimal
  • Returns Decimal

asinh

  • asinh(): Decimal
  • Returns Decimal

atan

  • atan(): Decimal
  • Returns Decimal

atanh

  • atanh(): Decimal
  • Returns Decimal

cbrt

  • cbrt(): Decimal
  • Returns Decimal

ceil

  • ceil(): Decimal
  • Returns Decimal

cmp

  • cmp(n: Decimal.Value): number
  • Parameters

    • n: Decimal.Value

    Returns number

comparedTo

  • comparedTo(n: Decimal.Value): number
  • Parameters

    • n: Decimal.Value

    Returns number

cos

  • cos(): Decimal
  • Returns Decimal

cosh

  • cosh(): Decimal
  • Returns Decimal

cosine

  • cosine(): Decimal
  • Returns Decimal

cubeRoot

  • cubeRoot(): Decimal
  • Returns Decimal

decimalPlaces

  • decimalPlaces(): number
  • Returns number

div

divToInt

  • divToInt(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

dividedBy

  • dividedBy(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

dividedToIntegerBy

  • dividedToIntegerBy(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

dp

  • dp(): number
  • Returns number

eq

  • eq(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

equals

  • equals(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

exp

  • exp(): Decimal
  • Returns Decimal

floor

  • floor(): Decimal
  • Returns Decimal

greaterThan

  • greaterThan(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

greaterThanOrEqualTo

  • greaterThanOrEqualTo(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

gt

  • gt(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

gte

  • gte(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

hyperbolicCosine

  • hyperbolicCosine(): Decimal
  • Returns Decimal

hyperbolicSine

  • hyperbolicSine(): Decimal
  • Returns Decimal

hyperbolicTangent

  • hyperbolicTangent(): Decimal
  • Returns Decimal

inverseCosine

  • inverseCosine(): Decimal
  • Returns Decimal

inverseHyperbolicCosine

  • inverseHyperbolicCosine(): Decimal

inverseHyperbolicSine

  • inverseHyperbolicSine(): Decimal

inverseHyperbolicTangent

  • inverseHyperbolicTangent(): Decimal

inverseSine

  • inverseSine(): Decimal
  • Returns Decimal

inverseTangent

  • inverseTangent(): Decimal
  • Returns Decimal

isFinite

  • isFinite(): boolean
  • Returns boolean

isInt

  • isInt(): boolean
  • Returns boolean

isInteger

  • isInteger(): boolean
  • Returns boolean

isNaN

  • isNaN(): boolean
  • Returns boolean

isNeg

  • isNeg(): boolean
  • Returns boolean

isNegative

  • isNegative(): boolean
  • Returns boolean

isPos

  • isPos(): boolean
  • Returns boolean

isPositive

  • isPositive(): boolean
  • Returns boolean

isZero

  • isZero(): boolean
  • Returns boolean

lessThan

  • lessThan(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

lessThanOrEqualTo

  • lessThanOrEqualTo(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

ln

  • ln(): Decimal
  • Returns Decimal

log

  • log(n?: Decimal.Value): Decimal
  • Parameters

    • Optional n: Decimal.Value

    Returns Decimal

logarithm

  • logarithm(n?: Decimal.Value): Decimal
  • Parameters

    • Optional n: Decimal.Value

    Returns Decimal

lt

  • lt(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

lte

  • lte(n: Decimal.Value): boolean
  • Parameters

    • n: Decimal.Value

    Returns boolean

minus

  • minus(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

mod

modulo

  • modulo(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

mul

naturalExponential

  • naturalExponential(): Decimal
  • Returns Decimal

naturalLogarithm

  • naturalLogarithm(): Decimal
  • Returns Decimal

neg

  • neg(): Decimal
  • Returns Decimal

negated

  • negated(): Decimal
  • Returns Decimal

plus

  • plus(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

pow

  • pow(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

precision

  • precision(includeZeros?: undefined | false | true): number
  • Parameters

    • Optional includeZeros: undefined | false | true

    Returns number

round

  • round(): Decimal
  • Returns Decimal

sd

  • sd(includeZeros?: undefined | false | true): number
  • Parameters

    • Optional includeZeros: undefined | false | true

    Returns number

sin

  • sin(): Decimal
  • Returns Decimal

sine

  • sine(): Decimal
  • Returns Decimal

sinh

  • sinh(): Decimal
  • Returns Decimal

sqrt

  • sqrt(): Decimal
  • Returns Decimal

squareRoot

  • squareRoot(): Decimal
  • Returns Decimal

sub

tan

  • tan(): Decimal
  • Returns Decimal

tangent

  • tangent(): Decimal
  • Returns Decimal

tanh

  • tanh(): Decimal
  • Returns Decimal

times

  • times(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

toBinary

  • toBinary(significantDigits?: undefined | number): string
  • toBinary(significantDigits: number, rounding: Decimal.Rounding): string
  • Parameters

    • Optional significantDigits: undefined | number

    Returns string

  • Parameters

    • significantDigits: number
    • rounding: Decimal.Rounding

    Returns string

toDP

  • toDP(decimalPlaces?: undefined | number): Decimal
  • toDP(decimalPlaces: number, rounding: Decimal.Rounding): Decimal
  • Parameters

    • Optional decimalPlaces: undefined | number

    Returns Decimal

  • Parameters

    • decimalPlaces: number
    • rounding: Decimal.Rounding

    Returns Decimal

toDecimalPlaces

  • toDecimalPlaces(decimalPlaces?: undefined | number): Decimal
  • toDecimalPlaces(decimalPlaces: number, rounding: Decimal.Rounding): Decimal
  • Parameters

    • Optional decimalPlaces: undefined | number

    Returns Decimal

  • Parameters

    • decimalPlaces: number
    • rounding: Decimal.Rounding

    Returns Decimal

toExponential

  • toExponential(decimalPlaces?: undefined | number): string
  • toExponential(decimalPlaces: number, rounding: Decimal.Rounding): string
  • Parameters

    • Optional decimalPlaces: undefined | number

    Returns string

  • Parameters

    • decimalPlaces: number
    • rounding: Decimal.Rounding

    Returns string

toFixed

  • toFixed(decimalPlaces?: undefined | number): string
  • toFixed(decimalPlaces: number, rounding: Decimal.Rounding): string
  • Parameters

    • Optional decimalPlaces: undefined | number

    Returns string

  • Parameters

    • decimalPlaces: number
    • rounding: Decimal.Rounding

    Returns string

toFraction

  • toFraction(max_denominator?: Decimal.Value): Decimal[]
  • Parameters

    • Optional max_denominator: Decimal.Value

    Returns Decimal[]

toHex

  • toHex(significantDigits?: undefined | number): string
  • toHex(significantDigits: number, rounding?: Decimal.Rounding): string
  • Parameters

    • Optional significantDigits: undefined | number

    Returns string

  • Parameters

    • significantDigits: number
    • Optional rounding: Decimal.Rounding

    Returns string

toHexadecimal

  • toHexadecimal(significantDigits?: undefined | number): string
  • toHexadecimal(significantDigits: number, rounding: Decimal.Rounding): string
  • Parameters

    • Optional significantDigits: undefined | number

    Returns string

  • Parameters

    • significantDigits: number
    • rounding: Decimal.Rounding

    Returns string

toInt

toJSON

  • toJSON(): string
  • Returns string

toNearest

  • toNearest(n: Decimal.Value, rounding?: Decimal.Rounding): Decimal
  • Parameters

    • n: Decimal.Value
    • Optional rounding: Decimal.Rounding

    Returns Decimal

toNumber

  • toNumber(): number
  • Returns number

toOctal

  • toOctal(significantDigits?: undefined | number): string
  • toOctal(significantDigits: number, rounding: Decimal.Rounding): string
  • Parameters

    • Optional significantDigits: undefined | number

    Returns string

  • Parameters

    • significantDigits: number
    • rounding: Decimal.Rounding

    Returns string

toPower

  • toPower(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

toPrecision

  • toPrecision(significantDigits?: undefined | number): string
  • toPrecision(significantDigits: number, rounding: Decimal.Rounding): string
  • Parameters

    • Optional significantDigits: undefined | number

    Returns string

  • Parameters

    • significantDigits: number
    • rounding: Decimal.Rounding

    Returns string

toSD

  • toSD(significantDigits?: undefined | number): Decimal
  • toSD(significantDigits: number, rounding: Decimal.Rounding): Decimal
  • Parameters

    • Optional significantDigits: undefined | number

    Returns Decimal

  • Parameters

    • significantDigits: number
    • rounding: Decimal.Rounding

    Returns Decimal

toSignificantDigits

  • toSignificantDigits(significantDigits?: undefined | number): Decimal
  • toSignificantDigits(significantDigits: number, rounding: Decimal.Rounding): Decimal
  • Parameters

    • Optional significantDigits: undefined | number

    Returns Decimal

  • Parameters

    • significantDigits: number
    • rounding: Decimal.Rounding

    Returns Decimal

toString

  • toString(): string
  • Returns string

trunc

  • trunc(): Decimal
  • Returns Decimal

truncated

  • truncated(): Decimal
  • Returns Decimal

valueOf

  • valueOf(): string
  • Returns string

Static abs

  • abs(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static acos

  • acos(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static acosh

  • acosh(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static add

  • add(x: Decimal.Value, y: Decimal.Value): Decimal
  • Parameters

    • x: Decimal.Value
    • y: Decimal.Value

    Returns Decimal

Static asin

  • asin(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static asinh

  • asinh(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static atan

  • atan(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static atan2

  • atan2(y: Decimal.Value, x: Decimal.Value): Decimal
  • Parameters

    • y: Decimal.Value
    • x: Decimal.Value

    Returns Decimal

Static atanh

  • atanh(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static cbrt

  • cbrt(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static ceil

  • ceil(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static clone

  • clone(object?: Decimal.Config): Decimal.Constructor
  • Parameters

    • Optional object: Decimal.Config

    Returns Decimal.Constructor

Static config

  • config(object: Config): Decimal.Constructor
  • Parameters

    Returns Decimal.Constructor

Static cos

  • cos(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static cosh

  • cosh(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static div

  • div(x: Decimal.Value, y: Decimal.Value): Decimal
  • Parameters

    • x: Decimal.Value
    • y: Decimal.Value

    Returns Decimal

Static exp

  • exp(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static floor

  • floor(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static hypot

  • hypot(...n: Decimal.Value[]): Decimal
  • Parameters

    • Rest ...n: Decimal.Value[]

    Returns Decimal

Static isDecimal

  • isDecimal(object: any): boolean
  • Parameters

    • object: any

    Returns boolean

Static ln

  • ln(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static log

  • log(n: Decimal.Value, base?: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value
    • Optional base: Decimal.Value

    Returns Decimal

Static log10

  • log10(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static log2

  • log2(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static max

  • max(...n: Decimal.Value[]): Decimal
  • Parameters

    • Rest ...n: Decimal.Value[]

    Returns Decimal

Static min

  • min(...n: Decimal.Value[]): Decimal
  • Parameters

    • Rest ...n: Decimal.Value[]

    Returns Decimal

Static mod

  • mod(x: Decimal.Value, y: Decimal.Value): Decimal
  • Parameters

    • x: Decimal.Value
    • y: Decimal.Value

    Returns Decimal

Static mul

  • mul(x: Decimal.Value, y: Decimal.Value): Decimal
  • Parameters

    • x: Decimal.Value
    • y: Decimal.Value

    Returns Decimal

Static noConflict

  • noConflict(): Decimal.Constructor
  • Returns Decimal.Constructor

Static pow

  • pow(base: Decimal.Value, exponent: Decimal.Value): Decimal
  • Parameters

    • base: Decimal.Value
    • exponent: Decimal.Value

    Returns Decimal

Static random

  • random(significantDigits?: undefined | number): Decimal
  • Parameters

    • Optional significantDigits: undefined | number

    Returns Decimal

Static round

  • round(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static set

  • set(object: Config): Decimal.Constructor
  • Parameters

    Returns Decimal.Constructor

Static sign

  • sign(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static sin

  • sin(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static sinh

  • sinh(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static sqrt

  • sqrt(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static sub

  • sub(x: Decimal.Value, y: Decimal.Value): Decimal
  • Parameters

    • x: Decimal.Value
    • y: Decimal.Value

    Returns Decimal

Static tan

  • tan(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static tanh

  • tanh(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static trunc

  • trunc(n: Decimal.Value): Decimal
  • Parameters

    • n: Decimal.Value

    Returns Decimal

Static withPrec

  • withPrec(value: Decimal.Value, prec: number): Dec

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Static property
  • Static method
  • Property

Generated using TypeDoc