Class BigInt

Additional static members for the native BigInt class.

Does not extend the native BigInt class.

Constructors

Methods

Constructors

Methods

  • Verify the type of bigint given, throwing if it does not match.

    Given a bigint and a "type", test to see if the argument is of that type. Mainly used for parameter validation, when the type bigint is not specific enough. The acceptable "types", which are not mutually exclusive, are members of NumericType:

    • NumericType.INTEGER : always matches: BigInts are always integers
    • NumericType.NATURAL : synonym of NumericType.NONNEGATIVE
    • NumericType.WHOLE : synonym of NumericType.POSITIVE
    • NumericType.FLOAT : never matches: BigInts are never non-integers
    • NumericType.POSITIVE : the bigint is strictly greater than 0n
    • NumericType.NEGATIVE : the bigint is strictly less than 0n
    • NumericType.NONPOSITIVE : the bigint is less than or equal to 0n
    • NumericType.NONNEGATIVE : the bigint is greater than or equal to 0n
    • NumericType.NONZERO : the bigint is not equal to 0n
    • NumericType.FINITE : always matches: BigInts are always finite
    • NumericType.INFINITE : never matches: BigInts are never finite
    • no type (undefiend): always matches

    If the argument matches the described type, this method returns void instead of true. If the argument does not match, this method throws an error instead of returning false. This pattern is helpful where an error message is more descriptive than a boolean.

    Parameters

    • int: bigint

      the argument to test

    • Optional type: NumericType

      one of the string literals listed above

    Returns void

    Throws

    if the argument does not match the described type