Function signedBigIntToBytes

  • Convert a signed bigint to a Uint8Array. This uses two's complement encoding to represent negative numbers.

    To convert an unsigned bigint to a Uint8Array instead, use bigIntToBytes.

    See

    https://en.wikipedia.org/wiki/Two%27s_complement

    Returns

    The bytes as Uint8Array.

    Parameters

    • value: bigint

      The number to convert to bytes.

    • byteLength: number

      The length of the resulting Uint8Array. If the number is larger than the maximum value that can be represented by the given length, an error is thrown.

    Returns Uint8Array