Skip to content

BigInt.ToBytes

Name Mandatory Description Default Type
⬅️ Input Big integer to convert, represented as bytes. Bytes
Output ➡️ The resulting output of the shard Bytes
Bits No The desired bit length for the output to take. If set to 0, the output will be the minimum number of bytes required to represent the big integer. 0 Int

This shard converts a big integer value into a bytes representaion with the specified bit length set in the Bits parameter. If set to 0, the output will be the minimum number of bytes required to represent the big integer. If set to a positive number, the output will be padded with leading zeros to match the specified bit length. An error is thrown if the number requires more bits than specified.

Examples

1
2
3
4
42 | BigInt
BigInt.ToBytes(Bits: 16)
ToHex
Assert.Is("0x002a" true)