Options
All
• Public
• Public/Protected
• All

# Class Decimal

A type for arbitrary precision, non-negative decimals.

Instances of this class are immutable.

• Decimal

## Accessors

• get atomics(): string
• get fractionalDigits(): number

## Methods

• Returns the smallest decimal >= this which has no fractional part (rounding up)

#### Returns boolean

• Returns the greatest decimal <= this which has no fractional part (rounding down)

#### Returns boolean

• isGreaterThanOrEqual(b: Decimal): boolean

#### Returns boolean

• isLessThanOrEqual(b: Decimal): boolean

#### Returns boolean

• a.minus(b) returns a-b.

Both values need to have the same fractional digits. The resulting difference needs to be non-negative.

#### Returns Decimal

• a.multiply(b) returns a*b.

We only allow multiplication by unsigned integers to avoid rounding errors.

#### Returns Decimal

• a.plus(b) returns a+b.

Both values need to have the same fractional digits.

#### Returns Decimal

• toFloatApproximation(): number
• Returns an approximation as a float type. Only use this if no exact calculation is required.

#### Returns number

• toString(): string

#### Returns number

• fromAtomics(atomics: string, fractionalDigits: number): Decimal

#### Returns Decimal

• fromUserInput(input: string, fractionalDigits: number): Decimal

#### Returns Decimal

• one(fractionalDigits: number): Decimal
• Creates a Decimal with value 1.0 and the given number of fractial digits.

Fractional digits are not relevant for the value but needed to be able to perform arithmetic operations with other decimals.

#### Returns Decimal

• zero(fractionalDigits: number): Decimal
• Creates a Decimal with value 0.0 and the given number of fractial digits.

Fractional digits are not relevant for the value but needed to be able to perform arithmetic operations with other decimals.

#### Returns Decimal

Generated using TypeDoc