Convert a bigint to a hexadecimal string. This verifies that the bigint is a non-negative integer.
bigint
To convert a number to a hexadecimal string instead, use numberToHex.
bigIntToHex(0n); // '0x0'bigIntToHex(1n); // '0x1'bigIntToHex(16n); // '0x10'
The hexadecimal string, with the "0x"-prefix.
If the bigint is not a non-negative integer.
The bigint to convert to a hexadecimal string.
Convert a
bigint
to a hexadecimal string. This verifies that thebigint
is a non-negative integer.To convert a number to a hexadecimal string instead, use numberToHex.
Example
Returns
The hexadecimal string, with the "0x"-prefix.
Throws
If the
bigint
is not a non-negative integer.