num_convert
Convert a big integer between hex, decimal, binary, and octal bases. Handles negative numbers, radix prefixes, and optional zero-padding, with arbitrary precision.
Instructions
Convert a big-integer between bases (hex/dec/bin/oct).
Parses value as a from_base integer (a leading 0x/0b/0o and a - sign
are accepted) and renders it in to_base, prefixed for non-decimal output.
pad_bytes zero-fills the output to that byte width (a minimum, never
truncating); it is bit-aligned, so it is rejected for decimal output.
Arbitrary precision — a 32-byte RPC value converts losslessly.
Returns {value, from_base, to_base, result}.
Example: num_convert("255", "dec", "hex") -> result "0xff"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| value | Yes | Integer to convert, read in `from_base`; a leading 0x/0b/0o radix prefix and a '-' sign are accepted. | |
| from_base | Yes | Base of `value`: hex (16), dec (10), bin (2), oct (8). | |
| to_base | Yes | Base to render the result in; non-decimal output is prefixed 0x/0b/0o. | |
| pad_bytes | No | Zero-fill the output to this byte width (a minimum, never truncating); bit-aligned, so rejected for decimal output. Default None means no padding. |