Options
All
  • Public
  • Public/Protected
  • All
Menu

Some amount of tokens Copied from token-swap, for packing instruction buffer correctly

Hierarchy

  • BN
    • Numberu64

Index

Constructors

  • new Numberu64(number: string | number | Buffer | BN | number[] | Uint8Array, base?: number | "hex", endian?: Endianness): Numberu64
  • new Numberu64(number: string | number | Buffer | BN | number[] | Uint8Array, endian?: Endianness): Numberu64
  • Parameters

    • number: string | number | Buffer | BN | number[] | Uint8Array
    • Optional base: number | "hex"
    • Optional endian: Endianness

    Returns Numberu64

  • Parameters

    • number: string | number | Buffer | BN | number[] | Uint8Array
    • Optional endian: Endianness

    Returns Numberu64

Properties

BN: typeof BN
wordSize: 26

Methods

  • abs(): BN
  • description

    absolute value

    Returns BN

  • add(b: BN): BN
  • description

    addition

    Parameters

    • b: BN

    Returns BN

  • addn(b: number): BN
  • description

    addition

    Parameters

    • b: number

    Returns BN

  • and(b: BN): BN
  • description

    and

    Parameters

    • b: BN

    Returns BN

  • andln(b: number): BN
  • description

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

    Parameters

    • b: number

    Returns BN

  • bincn(b: number): BN
  • description

    add 1 << b to the number

    Parameters

    • b: number

    Returns BN

  • bitLength(): number
  • description

    get number of bits occupied

    Returns number

  • byteLength(): number
  • description

    return number of bytes occupied

    Returns number

  • clone(): BN
  • description

    clone number

    Returns BN

  • cmp(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
  • 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

  • div(b: BN): BN
  • description

    divide

    Parameters

    • b: BN

    Returns BN

  • divRound(b: BN): BN
  • description

    rounded division

    Parameters

    • b: BN

    Returns BN

  • divn(b: number): BN
  • description

    divide

    Parameters

    • b: number

    Returns BN

  • egcd(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
  • eq(b: BN): boolean
  • description

    a equals b

    Parameters

    • b: BN

    Returns boolean

  • eqn(b: number): boolean
  • description

    a equals b

    Parameters

    • b: number

    Returns boolean

  • fromTwos(width: number): BN
  • description

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

    Parameters

    • width: number

    Returns BN

  • gcd(b: BN): BN
  • description

    GCD

    Parameters

    • b: BN

    Returns BN

  • gt(b: BN): boolean
  • description

    a greater than b

    Parameters

    • b: BN

    Returns boolean

  • gte(b: BN): boolean
  • description

    a greater than or equals b

    Parameters

    • b: BN

    Returns boolean

  • gten(b: number): boolean
  • description

    a greater than or equals b

    Parameters

    • b: number

    Returns boolean

  • gtn(b: number): boolean
  • description

    a greater than b

    Parameters

    • b: number

    Returns boolean

  • iabs(): BN
  • description

    absolute value

    Returns BN

  • iadd(b: BN): BN
  • description

    addition

    Parameters

    • b: BN

    Returns BN

  • iaddn(b: number): BN
  • description

    addition

    Parameters

    • b: number

    Returns BN

  • iand(b: BN): BN
  • description

    and

    Parameters

    • b: BN

    Returns BN

  • idivn(b: number): BN
  • description

    divide

    Parameters

    • b: number

    Returns BN

  • imaskn(b: number): BN
  • description

    clear bits with indexes higher or equal to b

    Parameters

    • b: number

    Returns BN

  • imul(b: BN): BN
  • description

    multiply

    Parameters

    • b: BN

    Returns BN

  • imuln(b: number): BN
  • description

    multiply

    Parameters

    • b: number

    Returns BN

  • ineg(): BN
  • description

    negate sign

    Returns BN

  • inotn(w: number): BN
  • description

    not (for the width specified by w)

    Parameters

    • w: number

    Returns BN

  • invm(b: BN): BN
  • description

    inverse a modulo b

    Parameters

    • b: BN

    Returns BN

  • ior(b: BN): BN
  • description

    or

    Parameters

    • b: BN

    Returns BN

  • isEven(): boolean
  • description

    check if value is even

    Returns boolean

  • isNeg(): boolean
  • description

    true if the number is negative

    Returns boolean

  • isOdd(): boolean
  • description

    check if value is odd

    Returns boolean

  • isZero(): boolean
  • description

    check if value is zero

    Returns boolean

  • ishln(b: number): BN
  • description

    shift left

    Parameters

    • b: number

    Returns BN

  • ishrn(b: number): BN
  • isqr(): BN
  • description

    square

    Returns BN

  • isub(b: BN): BN
  • description

    subtraction

    Parameters

    • b: BN

    Returns BN

  • isubn(b: number): BN
  • description

    subtraction

    Parameters

    • b: number

    Returns BN

  • iuand(b: BN): BN
  • description

    and

    Parameters

    • b: BN

    Returns BN

  • iuor(b: BN): BN
  • description

    or

    Parameters

    • b: BN

    Returns BN

  • iushln(b: number): BN
  • description

    shift left

    Parameters

    • b: number

    Returns BN

  • iushrn(b: number): BN
  • description

    shift right

    Parameters

    • b: number

    Returns BN

  • iuxor(b: BN): BN
  • description

    xor

    Parameters

    • b: BN

    Returns BN

  • ixor(b: BN): BN
  • description

    xor

    Parameters

    • b: BN

    Returns BN

  • lt(b: BN): boolean
  • description

    a less than b

    Parameters

    • b: BN

    Returns boolean

  • lte(b: BN): boolean
  • description

    a less than or equals b

    Parameters

    • b: BN

    Returns boolean

  • lten(b: number): boolean
  • description

    a less than or equals b

    Parameters

    • b: number

    Returns boolean

  • ltn(b: number): boolean
  • description

    a less than b

    Parameters

    • b: number

    Returns boolean

  • maskn(b: number): BN
  • description

    clear bits with indexes higher or equal to b

    Parameters

    • b: number

    Returns BN

  • mod(b: BN): BN
  • description

    reduct

    Parameters

    • b: BN

    Returns BN

  • modn(b: number): number
  • deprecated
    description

    reduct

    Parameters

    • b: number

    Returns number

  • modrn(b: number): number
  • description

    reduct

    Parameters

    • b: number

    Returns number

  • mul(b: BN): BN
  • description

    multiply

    Parameters

    • b: BN

    Returns BN

  • muln(b: number): BN
  • description

    multiply

    Parameters

    • b: number

    Returns BN

  • neg(): BN
  • description

    negate sign

    Returns BN

  • notn(w: number): BN
  • description

    not (for the width specified by w)

    Parameters

    • w: number

    Returns BN

  • or(b: BN): BN
  • description

    or

    Parameters

    • b: BN

    Returns BN

  • pow(b: BN): BN
  • description

    raise a to the power of b

    Parameters

    • b: BN

    Returns BN

  • Saturating sub

    Parameters

    Returns Numberu64

  • setn(b: number): BN
  • description

    set specified bit to 1

    Parameters

    • b: number

    Returns BN

  • shln(b: number): BN
  • description

    shift left

    Parameters

    • b: number

    Returns BN

  • shrn(b: number): BN
  • description

    shift right

    Parameters

    • b: number

    Returns BN

  • sqr(): BN
  • description

    square

    Returns BN

  • sub(b: BN): BN
  • description

    subtraction

    Parameters

    • b: BN

    Returns BN

  • subn(b: number): BN
  • description

    subtraction

    Parameters

    • b: number

    Returns BN

  • testn(b: number): boolean
  • description

    test if specified bit is set

    Parameters

    • b: number

    Returns boolean

  • toArray(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
  • toArrayLike(ArrayType: any[], endian?: Endianness, length?: number): any[]
  • description

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

    Parameters

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

    Returns Buffer

  • Parameters

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

    Returns any[]

  • toBuffer(): Buffer
  • Convert to Buffer representation

    Returns Buffer

  • toJSON(): string
  • description

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

    Returns string

  • toNumber(): number
  • description

    convert to Javascript Number (limited to 53 bits)

    Returns number

  • toRed(reductionContext: ReductionContext): RedBN
  • description

    Convert number to red

    Parameters

    • reductionContext: ReductionContext

    Returns RedBN

  • toString(base?: number | "hex", length?: number): string
  • description

    convert to base-string and pad with zeroes

    Parameters

    • Optional base: number | "hex"
    • Optional length: number

    Returns string

  • toTwos(width: number): BN
  • description

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

    Parameters

    • width: number

    Returns BN

  • uand(b: BN): BN
  • description

    and

    Parameters

    • b: BN

    Returns BN

  • ucmp(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

  • umod(b: BN): BN
  • description

    reduct

    Parameters

    • b: BN

    Returns BN

  • uor(b: BN): BN
  • description

    or

    Parameters

    • b: BN

    Returns BN

  • ushln(b: number): BN
  • description

    shift left

    Parameters

    • b: number

    Returns BN

  • ushrn(b: number): BN
  • description

    shift right

    Parameters

    • b: number

    Returns BN

  • uxor(b: BN): BN
  • description

    xor

    Parameters

    • b: BN

    Returns BN

  • xor(b: BN): BN
  • description

    xor

    Parameters

    • b: BN

    Returns BN

  • zeroBits(): number
  • description

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

    Returns number

  • Creates a new Numberu64 with the same value as an existing BN new Numberu64(bn) doesnt work, only copies the reference and doesnt override toBuffer(), so any BNs with buffer length < 8's this.toBuffer() will return short buffer that cant be serialized to TransactionInstruction

    Parameters

    • bn: BN

    Returns Numberu64

  • Construct a Numberu64 from Buffer representation

    Parameters

    • buffer: Buffer

    Returns Numberu64

  • isBN(b: any): b is BN
  • description

    returns true if the supplied object is a BN.js instance

    Parameters

    • b: any

    Returns b is BN

  • max(left: BN, right: BN): BN
  • description

    returns the maximum of 2 BN instances.

    Parameters

    • left: BN
    • right: BN

    Returns BN

  • min(left: BN, right: BN): BN
  • description

    returns the minimum of 2 BN instances.

    Parameters

    • left: BN
    • right: BN

    Returns BN

  • mont(num: BN): ReductionContext
  • description

    create a reduction context with the Montgomery trick.

    Parameters

    • num: BN

    Returns ReductionContext

  • red(reductionContext: BN | IPrimeName): ReductionContext
  • description

    create a reduction context

    Parameters

    • reductionContext: BN | IPrimeName

    Returns ReductionContext

Generated using TypeDoc