Interface Decimal

Decimal type

interface Decimal {
    Abs(): Decimal;
    Add(d2): Decimal;
    Ceil(): Decimal;
    Cmp(d2): number;
    Div(d2): Decimal;
    Equal(d2): boolean;
    Exponent(): number;
    Floor(): Decimal;
    GreaterThan(d2): boolean;
    GreaterThanOrEqual(d2): boolean;
    InexactFloat64(): number;
    IntPart(): number;
    LessThan(d2): boolean;
    LessThanOrEqual(d2): boolean;
    Mod(d2): Decimal;
    Mul(d2): Decimal;
    Neg(): Decimal;
    Pow(d2): Decimal;
    Sign(): number;
    String(): string;
    StringFixed(places): string;
    Sub(d2): Decimal;
    Truncate(precision): Decimal;
}

Methods

  • Parameters

    Returns number

  • Parameters

    Returns boolean

  • Returns number

  • Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Returns number

  • Returns number

  • Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Returns number

  • Returns string

  • StringFixed returns a rounded fixed-point string with places digits after the decimal point.

    Parameters

    • places: number

    Returns string

    Example


    newFromFloat(0).StringFixed(2) // output: "0.00"
    newFromFloat(0).StringFixed(0) // output: "0"
    newFromFloat(5.45).StringFixed(0) // output: "5"
    newFromFloat(5.45).StringFixed(1) // output: "5.5"
    newFromFloat(5.45).StringFixed(2) // output: "5.45"
    newFromFloat(5.45).StringFixed(3) // output: "5.450"
    newFromFloat(545).StringFixed(-1) // output: "550"
  • Parameters

    • precision: number

    Returns Decimal