exactnumber
    Preparing search index...

    Interface ExactNumberType

    interface ExactNumberType {
        type: "fraction" | "fixed";
        abs(): ExactNumberType;
        add(x: string | number | bigint | ExactNumberType): ExactNumberType;
        bitwiseAnd(x: string | number | bigint | ExactNumberType): ExactNumberType;
        bitwiseOr(x: string | number | bigint | ExactNumberType): ExactNumberType;
        bitwiseXor(x: string | number | bigint | ExactNumberType): ExactNumberType;
        ceil(decimals?: number): ExactNumberType;
        clamp(
            min: string | number | bigint | ExactNumberType,
            max: string | number | bigint | ExactNumberType,
        ): ExactNumberType;
        cmp(x: string | number | bigint | ExactNumberType): -1 | 0 | 1;
        div(x: string | number | bigint | ExactNumberType): ExactNumberType;
        divToInt(x: string | number | bigint | ExactNumberType): ExactNumberType;
        eq(x: string | number | bigint | ExactNumberType): boolean;
        floor(decimals?: number): ExactNumberType;
        fracPart(): ExactNumberType;
        getFractionParts(
            normalize?: boolean,
        ): { denominator: ExactNumberType; numerator: ExactNumberType };
        gt(x: string | number | bigint | ExactNumberType): boolean;
        gte(x: string | number | bigint | ExactNumberType): boolean;
        intPart(): ExactNumberType;
        inv(): ExactNumberType;
        isInteger(): boolean;
        isNegative(): boolean;
        isOne(): boolean;
        isZero(): boolean;
        limitDecimals(
            maxDecimals: number,
            roundingMode?: RoundingMode,
        ): ExactNumberType;
        lt(x: string | number | bigint | ExactNumberType): boolean;
        lte(x: string | number | bigint | ExactNumberType): boolean;
        mod(
            x: string | number | bigint | ExactNumberType,
            type?: ModType,
        ): ExactNumberType;
        mul(x: string | number | bigint | ExactNumberType): ExactNumberType;
        neg(): ExactNumberType;
        normalize(): ExactNumberType;
        pow(x: string | number | bigint | ExactNumberType): ExactNumberType;
        powm(
            exponent: string | number | bigint | ExactNumberType,
            modulus: string | number | bigint | ExactNumberType,
            type?: ModType,
        ): ExactNumberType;
        round(decimals?: number, roundingMode?: RoundingMode): ExactNumberType;
        roundToDigits(digits: number, roundingMode: RoundingMode): ExactNumberType;
        shiftLeft(bitCount: number): ExactNumberType;
        shiftRight(bitCount: number): ExactNumberType;
        sign(): -1 | 1;
        sub(x: string | number | bigint | ExactNumberType): ExactNumberType;
        toExponential(
            digits: number,
            roundingMode?: RoundingMode,
            trimZeros?: boolean,
        ): string;
        toFixed(
            decimals: number,
            roundingMode?: RoundingMode,
            trimZeros?: boolean,
        ): string;
        toFraction(): string;
        toNumber(): number;
        toPrecision(
            digits: number,
            roundingMode?: RoundingMode,
            trimZeros?: boolean,
        ): string;
        toString(radix?: number, maxDigits?: number): string;
        trunc(decimals?: number): ExactNumberType;
    }
    Index

    Properties

    type: "fraction" | "fixed"

    Methods

    • Returns a number which is rounded up to the next largest integer. Same as round(RoundingMode.TO_POSITIVE).

      Parameters

      • Optionaldecimals: number

      Returns ExactNumberType

    • Compares the current number to the provided number. Returns -1 when the provided number is smaller than the current one. Returns 0 when the provided number is equal with the current one. Returns 1 when the provided number is greater than the current one.

      Parameters

      Returns -1 | 0 | 1

    • Returns true if the current number is equal to the provided number

      Parameters

      Returns boolean

    • Returns the largest number, but less than or equal to the current number. Same as round(RoundingMode.TO_NEGATIVE).

      Parameters

      • Optionaldecimals: number

      Returns ExactNumberType

    • Returns true if the current number is greater than the provided number

      Parameters

      Returns boolean

    • Returns true if the current number is greater than or equal to the provided number

      Parameters

      Returns boolean

    • Returns true if the number does not have a fractional part.

      Returns boolean

    • Returns true if the number is negative.

      Returns boolean

    • Returns true if the number is equal with one.

      Returns boolean

    • Returns true if the number is equal with zero.

      Returns boolean

    • Ensures that number can be represented with specified amount of decimals. In contrary to round(), this function keeps the repeating decimals in place if cycle length fits into the limit. RoundingMode.NEAREST_TO_POSITIVE is the default

      Parameters

      Returns ExactNumberType

    • Returns true if the current number is less than the provided number

      Parameters

      Returns boolean

    • Returns true if the current number is less than or equal to the provided number

      Parameters

      Returns boolean

    • Returns opimized internal representation of the current number (e.g. it simplifies fractions using GCD) This is may be a slow operation, but in some cases normalization might help with performance of repeated operations.

      Returns ExactNumberType

    • Returns the sign of the current value as a number (-1 or 1)

      Returns -1 | 1

    • Returns a string representing the number in exponential notation. Defaults to RoundingMode.TO_ZERO

      Parameters

      • digits: number
      • OptionalroundingMode: RoundingMode
      • OptionaltrimZeros: boolean

      Returns string

    • Returns a string representing the number using fixed-point notation, rounded to the specified number of decimals. Defaults to RoundingMode.TO_ZERO

      Parameters

      • decimals: number
      • OptionalroundingMode: RoundingMode
      • OptionaltrimZeros: boolean

      Returns string

    • Returns string representation of the current number in a fractional format like "1/2". It always simplifies the fraction before output.

      Returns string

    • Converts current value to a JavaScript Number

      Returns number

    • Returns a string representing the number using fixed-point notation, rounded to the specified number of significant digits. In contrary to JS Number.toPrecision(), this function never returns exponential notation. Defaults to RoundingMode.TO_ZERO

      Parameters

      • digits: number
      • OptionalroundingMode: RoundingMode
      • OptionaltrimZeros: boolean

      Returns string

    • Returns string representation in decimal format. The result might contain repeating digit sequences formatted like "1.4(3)" It is recommended to set a maximum length for the fractional part to avoid performance issues when having long cycles. When such limit is provided, toString() truncates the undesired digits

      Parameters

      • Optionalradix: number
      • OptionalmaxDigits: number

      Returns string

    • Truncates the number to the specified number of decimals. Same as round(RoundingMode.TO_ZERO).

      Parameters

      • Optionaldecimals: number

      Returns ExactNumberType