Type alias BigNumber

BigNumber: {
    clone: (() => BN);
    toString: ((base?: number | "hex", length?: number) => string) & (() => string);
    toNumber: (() => number);
    toJSON: (() => string);
    toArray: ((endian?: Endianness, length?: number) => number[]);
    toArrayLike: {
        (ArrayType: BufferConstructor, endian?: Endianness, length?: number): Buffer;
        (ArrayType: any[], endian?: Endianness, length?: number): any[];
    };
    toBuffer: ((endian?: Endianness, length?: number) => Buffer);
    bitLength: (() => number);
    zeroBits: (() => number);
    byteLength: (() => number);
    isNeg: (() => boolean);
    isEven: (() => boolean);
    isOdd: (() => boolean);
    isZero: (() => boolean);
    cmp: ((b: BN) => 0 | 1 | -1);
    ucmp: ((b: BN) => 0 | 1 | -1);
    cmpn: ((b: number) => 0 | 1 | -1);
    lt: ((b: BN) => boolean);
    ltn: ((b: number) => boolean);
    lte: ((b: BN) => boolean);
    lten: ((b: number) => boolean);
    gt: ((b: BN) => boolean);
    gtn: ((b: number) => boolean);
    gte: ((b: BN) => boolean);
    gten: ((b: number) => boolean);
    eq: ((b: BN) => boolean);
    eqn: ((b: number) => boolean);
    toTwos: ((width: number) => BN);
    fromTwos: ((width: number) => BN);
    neg: (() => BN);
    ineg: (() => BN);
    abs: (() => BN);
    iabs: (() => BN);
    add: ((b: BN) => BN);
    iadd: ((b: BN) => BN);
    addn: ((b: number) => BN);
    iaddn: ((b: number) => BN);
    sub: ((b: BN) => BN);
    isub: ((b: BN) => BN);
    subn: ((b: number) => BN);
    isubn: ((b: number) => BN);
    mul: ((b: BN) => BN);
    imul: ((b: BN) => BN);
    muln: ((b: number) => BN);
    imuln: ((b: number) => BN);
    sqr: (() => BN);
    isqr: (() => BN);
    pow: ((b: BN) => BN);
    div: ((b: BN) => BN);
    divn: ((b: number) => BN);
    idivn: ((b: number) => BN);
    divmod: ((b: BN, mode?: "div" | "mod", positive?: boolean) => {
        div: BN;
        mod: BN;
    });
    mod: ((b: BN) => BN);
    umod: ((b: BN) => BN);
    modn: ((b: number) => number);
    modrn: ((b: number) => number);
    divRound: ((b: BN) => BN);
    or: ((b: BN) => BN);
    ior: ((b: BN) => BN);
    uor: ((b: BN) => BN);
    iuor: ((b: BN) => BN);
    and: ((b: BN) => BN);
    iand: ((b: BN) => BN);
    uand: ((b: BN) => BN);
    iuand: ((b: BN) => BN);
    andln: ((b: number) => BN);
    xor: ((b: BN) => BN);
    ixor: ((b: BN) => BN);
    uxor: ((b: BN) => BN);
    iuxor: ((b: BN) => BN);
    setn: ((b: number) => BN);
    shln: ((b: number) => BN);
    ishln: ((b: number) => BN);
    ushln: ((b: number) => BN);
    iushln: ((b: number) => BN);
    shrn: ((b: number) => BN);
    ishrn: ((b: number) => BN);
    ushrn: ((b: number) => BN);
    iushrn: ((b: number) => BN);
    testn: ((b: number) => boolean);
    maskn: ((b: number) => BN);
    imaskn: ((b: number) => BN);
    bincn: ((b: number) => BN);
    notn: ((w: number) => BN);
    inotn: ((w: number) => BN);
    gcd: ((b: BN) => BN);
    egcd: ((b: BN) => {
        a: BN;
        b: BN;
        gcd: BN;
    });
    invm: ((b: BN) => BN);
    toRed: ((reductionContext: ReductionContext) => RedBN);
    __opaque__: "BigNumber";
}

Type declaration

  • clone: (() => BN)
      • (): BN
      • Description

        clone number

        Returns BN

  • toString: ((base?: number | "hex", length?: number) => string) & (() => string)
  • toNumber: (() => number)
      • (): number
      • Description

        convert to Javascript Number (limited to 53 bits)

        Returns number

  • toJSON: (() => string)
      • (): string
      • Description

        convert to JSON compatible hex string (alias of toString(16))

        Returns string

  • toArray: ((endian?: Endianness, length?: number) => number[])
      • (endian?: Endianness, length?: number): number[]
      • Description

        convert to byte Array, and optionally zero pad to length, throwing if already exceeding

        Parameters

        • Optional endian: Endianness
        • Optional length: number

        Returns number[]

  • toArrayLike: {
        (ArrayType: BufferConstructor, endian?: Endianness, length?: number): Buffer;
        (ArrayType: any[], endian?: Endianness, length?: number): any[];
    }
      • (ArrayType: BufferConstructor, endian?: Endianness, length?: number): Buffer
      • Description

        convert to an instance of type, which must behave like an Array

        Parameters

        • ArrayType: BufferConstructor
        • Optional endian: Endianness
        • Optional length: number

        Returns Buffer

      • (ArrayType: any[], endian?: Endianness, length?: number): any[]
      • Parameters

        • ArrayType: any[]
        • Optional endian: Endianness
        • Optional length: number

        Returns any[]

  • toBuffer: ((endian?: Endianness, length?: number) => Buffer)
      • (endian?: Endianness, length?: number): Buffer
      • Description

        convert to Node.js Buffer (if available). For compatibility with browserify and similar tools, use this instead: a.toArrayLike(Buffer, endian, length)

        Parameters

        • Optional endian: Endianness
        • Optional length: number

        Returns Buffer

  • bitLength: (() => number)
      • (): number
      • Description

        get number of bits occupied

        Returns number

  • zeroBits: (() => number)
      • (): number
      • Description

        return number of less-significant consequent zero bits (example: 1010000 has 4 zero bits)

        Returns number

  • byteLength: (() => number)
      • (): number
      • Description

        return number of bytes occupied

        Returns number

  • isNeg: (() => boolean)
      • (): boolean
      • Description

        true if the number is negative

        Returns boolean

  • isEven: (() => boolean)
      • (): boolean
      • Description

        check if value is even

        Returns boolean

  • isOdd: (() => boolean)
      • (): boolean
      • Description

        check if value is odd

        Returns boolean

  • isZero: (() => boolean)
      • (): boolean
      • Description

        check if value is zero

        Returns boolean

  • cmp: ((b: BN) => 0 | 1 | -1)
      • (b: BN): 0 | 1 | -1
      • Description

        compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

        Parameters

        • b: BN

        Returns 0 | 1 | -1

  • ucmp: ((b: BN) => 0 | 1 | -1)
      • (b: BN): 0 | 1 | -1
      • Description

        compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

        Parameters

        • b: BN

        Returns 0 | 1 | -1

  • cmpn: ((b: number) => 0 | 1 | -1)
      • (b: number): 0 | 1 | -1
      • Description

        compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

        Parameters

        • b: number

        Returns 0 | 1 | -1

  • lt: ((b: BN) => boolean)
      • (b: BN): boolean
      • Description

        a less than b

        Parameters

        • b: BN

        Returns boolean

  • ltn: ((b: number) => boolean)
      • (b: number): boolean
      • Description

        a less than b

        Parameters

        • b: number

        Returns boolean

  • lte: ((b: BN) => boolean)
      • (b: BN): boolean
      • Description

        a less than or equals b

        Parameters

        • b: BN

        Returns boolean

  • lten: ((b: number) => boolean)
      • (b: number): boolean
      • Description

        a less than or equals b

        Parameters

        • b: number

        Returns boolean

  • gt: ((b: BN) => boolean)
      • (b: BN): boolean
      • Description

        a greater than b

        Parameters

        • b: BN

        Returns boolean

  • gtn: ((b: number) => boolean)
      • (b: number): boolean
      • Description

        a greater than b

        Parameters

        • b: number

        Returns boolean

  • gte: ((b: BN) => boolean)
      • (b: BN): boolean
      • Description

        a greater than or equals b

        Parameters

        • b: BN

        Returns boolean

  • gten: ((b: number) => boolean)
      • (b: number): boolean
      • Description

        a greater than or equals b

        Parameters

        • b: number

        Returns boolean

  • eq: ((b: BN) => boolean)
      • (b: BN): boolean
      • Description

        a equals b

        Parameters

        • b: BN

        Returns boolean

  • eqn: ((b: number) => boolean)
      • (b: number): boolean
      • Description

        a equals b

        Parameters

        • b: number

        Returns boolean

  • toTwos: ((width: number) => BN)
      • (width: number): BN
      • Description

        convert to two's complement representation, where width is bit width

        Parameters

        • width: number

        Returns BN

  • fromTwos: ((width: number) => BN)
      • (width: number): BN
      • Description

        convert from two's complement representation, where width is the bit width

        Parameters

        • width: number

        Returns BN

  • neg: (() => BN)
      • (): BN
      • Description

        negate sign

        Returns BN

  • ineg: (() => BN)
      • (): BN
      • Description

        negate sign

        Returns BN

  • abs: (() => BN)
      • (): BN
      • Description

        absolute value

        Returns BN

  • iabs: (() => BN)
      • (): BN
      • Description

        absolute value

        Returns BN

  • add: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        addition

        Parameters

        • b: BN

        Returns BN

  • iadd: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        addition

        Parameters

        • b: BN

        Returns BN

  • addn: ((b: number) => BN)
      • (b: number): BN
      • Description

        addition

        Parameters

        • b: number

        Returns BN

  • iaddn: ((b: number) => BN)
      • (b: number): BN
      • Description

        addition

        Parameters

        • b: number

        Returns BN

  • sub: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        subtraction

        Parameters

        • b: BN

        Returns BN

  • isub: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        subtraction

        Parameters

        • b: BN

        Returns BN

  • subn: ((b: number) => BN)
      • (b: number): BN
      • Description

        subtraction

        Parameters

        • b: number

        Returns BN

  • isubn: ((b: number) => BN)
      • (b: number): BN
      • Description

        subtraction

        Parameters

        • b: number

        Returns BN

  • mul: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        multiply

        Parameters

        • b: BN

        Returns BN

  • imul: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        multiply

        Parameters

        • b: BN

        Returns BN

  • muln: ((b: number) => BN)
      • (b: number): BN
      • Description

        multiply

        Parameters

        • b: number

        Returns BN

  • imuln: ((b: number) => BN)
      • (b: number): BN
      • Description

        multiply

        Parameters

        • b: number

        Returns BN

  • sqr: (() => BN)
      • (): BN
      • Description

        square

        Returns BN

  • isqr: (() => BN)
      • (): BN
      • Description

        square

        Returns BN

  • pow: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        raise a to the power of b

        Parameters

        • b: BN

        Returns BN

  • div: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        divide

        Parameters

        • b: BN

        Returns BN

  • divn: ((b: number) => BN)
      • (b: number): BN
      • Description

        divide

        Parameters

        • b: number

        Returns BN

  • idivn: ((b: number) => BN)
      • (b: number): BN
      • Description

        divide

        Parameters

        • b: number

        Returns BN

  • divmod: ((b: BN, mode?: "div" | "mod", positive?: boolean) => {
        div: BN;
        mod: BN;
    })
      • (b: BN, mode?: "div" | "mod", positive?: boolean): {
            div: BN;
            mod: BN;
        }
      • Description

        division with remainder

        Parameters

        • b: BN
        • Optional mode: "div" | "mod"
        • Optional positive: boolean

        Returns {
            div: BN;
            mod: BN;
        }

        • div: BN
        • mod: BN
  • mod: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        reduct

        Parameters

        • b: BN

        Returns BN

  • umod: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        reduct

        Parameters

        • b: BN

        Returns BN

  • modn: ((b: number) => number)
      • (b: number): number
      • Deprecated

        Description

        reduct

        Parameters

        • b: number

        Returns number

  • modrn: ((b: number) => number)
      • (b: number): number
      • Description

        reduct

        Parameters

        • b: number

        Returns number

  • divRound: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        rounded division

        Parameters

        • b: BN

        Returns BN

  • or: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        or

        Parameters

        • b: BN

        Returns BN

  • ior: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        or

        Parameters

        • b: BN

        Returns BN

  • uor: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        or

        Parameters

        • b: BN

        Returns BN

  • iuor: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        or

        Parameters

        • b: BN

        Returns BN

  • and: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        and

        Parameters

        • b: BN

        Returns BN

  • iand: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        and

        Parameters

        • b: BN

        Returns BN

  • uand: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        and

        Parameters

        • b: BN

        Returns BN

  • iuand: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        and

        Parameters

        • b: BN

        Returns BN

  • andln: ((b: number) => BN)
      • (b: number): BN
      • Description

        and (NOTE: andln is going to be replaced with andn in future)

        Parameters

        • b: number

        Returns BN

  • xor: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        xor

        Parameters

        • b: BN

        Returns BN

  • ixor: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        xor

        Parameters

        • b: BN

        Returns BN

  • uxor: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        xor

        Parameters

        • b: BN

        Returns BN

  • iuxor: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        xor

        Parameters

        • b: BN

        Returns BN

  • setn: ((b: number) => BN)
      • (b: number): BN
      • Description

        set specified bit to 1

        Parameters

        • b: number

        Returns BN

  • shln: ((b: number) => BN)
      • (b: number): BN
      • Description

        shift left

        Parameters

        • b: number

        Returns BN

  • ishln: ((b: number) => BN)
      • (b: number): BN
      • Description

        shift left

        Parameters

        • b: number

        Returns BN

  • ushln: ((b: number) => BN)
      • (b: number): BN
      • Description

        shift left

        Parameters

        • b: number

        Returns BN

  • iushln: ((b: number) => BN)
      • (b: number): BN
      • Description

        shift left

        Parameters

        • b: number

        Returns BN

  • shrn: ((b: number) => BN)
      • (b: number): BN
      • Description

        shift right

        Parameters

        • b: number

        Returns BN

  • ishrn: ((b: number) => BN)
  • ushrn: ((b: number) => BN)
      • (b: number): BN
      • Description

        shift right

        Parameters

        • b: number

        Returns BN

  • iushrn: ((b: number) => BN)
      • (b: number): BN
      • Description

        shift right

        Parameters

        • b: number

        Returns BN

  • testn: ((b: number) => boolean)
      • (b: number): boolean
      • Description

        test if specified bit is set

        Parameters

        • b: number

        Returns boolean

  • maskn: ((b: number) => BN)
      • (b: number): BN
      • Description

        clear bits with indexes higher or equal to b

        Parameters

        • b: number

        Returns BN

  • imaskn: ((b: number) => BN)
      • (b: number): BN
      • Description

        clear bits with indexes higher or equal to b

        Parameters

        • b: number

        Returns BN

  • bincn: ((b: number) => BN)
      • (b: number): BN
      • Description

        add 1 << b to the number

        Parameters

        • b: number

        Returns BN

  • notn: ((w: number) => BN)
      • (w: number): BN
      • Description

        not (for the width specified by w)

        Parameters

        • w: number

        Returns BN

  • inotn: ((w: number) => BN)
      • (w: number): BN
      • Description

        not (for the width specified by w)

        Parameters

        • w: number

        Returns BN

  • gcd: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        GCD

        Parameters

        • b: BN

        Returns BN

  • egcd: ((b: BN) => {
        a: BN;
        b: BN;
        gcd: BN;
    })
      • (b: BN): {
            a: BN;
            b: BN;
            gcd: BN;
        }
      • Description

        Extended GCD results ({ a: ..., b: ..., gcd: ... })

        Parameters

        • b: BN

        Returns {
            a: BN;
            b: BN;
            gcd: BN;
        }

        • a: BN
        • b: BN
        • gcd: BN
  • invm: ((b: BN) => BN)
      • (b: BN): BN
      • Description

        inverse a modulo b

        Parameters

        • b: BN

        Returns BN

  • toRed: ((reductionContext: ReductionContext) => RedBN)
      • (reductionContext: ReductionContext): RedBN
      • Description

        Convert number to red

        Parameters

        • reductionContext: ReductionContext

        Returns RedBN

  • __opaque__: "BigNumber"

Generated using TypeDoc