A command-line utility for converting integers between binary, octal, decimal, and hexadecimal bases.
pip install convbaseOr with uv:
uv tool install convbase| Command | Output base |
|---|---|
bin |
Binary (0b) |
oct |
Octal (0o) |
dec |
Decimal |
hex |
Hexadecimal (0x) |
All commands accept VALUE in any of the following formats:
| Format | Prefix | Example |
|---|---|---|
| Decimal | (none) | 10 |
| Binary | 0b |
0b1010 |
| Octal | 0o |
0o12 |
| Hexadecimal | 0x |
0xA |
$ bin 10
0b1010
$ bin 0xFF
0b11111111
$ oct 0b1010
0o12
$ oct 0xA
0o12
$ dec 0b1010
10
$ dec 0xFF
255
$ hex 10
0xa
$ hex 0b11111111
0xffPassing a value that cannot be parsed as an integer exits with a non-zero status and prints an error:
$ bin hello
Error: Invalid value for 'VALUE': invalid integer: 'hello'git clone https://github.com/jkomalley/convbase
cd convbase
just setup
just all # lint, type-check, and testMIT