Skip to content

bigIntToBytesBe

bigIntToBytesBe(value, byteLength?): Uint8Array<ArrayBuffer>

Defined in: packages/core/src/big-int/to-bytes-be.ts:18

Encodes a bigint as two’s complement, big-endian bytes.

What Java’s BigInteger.toByteArray and Python’s int.to_bytes produce. Reach for bigIntToBytesLe when the least significant byte comes first, and for @ac-kit/math-integer’s limb32/limb64 families when the digits feed arithmetic rather than a wire: those are little-endian, unsigned, and of fixed width.

Time complexity: O(n) in the byte count.

bigint

The value to encode. Zero encodes as a single 0x00.

number

Fixed output width, sign-extended to fit. Omit for the minimal encoding.

Uint8Array<ArrayBuffer>

A fresh buffer, never empty.

When byteLength is too small to hold value.