Skip to main content

Description

A CLI tool to convert numbers between bases, with as little typing as possible.

$ bs FFFE
[from hexadecimal]
  decimal     65534
  binary      1111111111111110
  octal       177776
$ bs -t d F
15

Installation

This is a Python 3 script, installed from PyPI using pip.

pip3 install base-convert-cli

Hasn't been tested on Windows.

Examples

If you don't specify a base, it does all common conversions.

$ bs 0
[from decimal]
  binary      0
  hexadecimal 0
  octal       0

[from binary]
<clipped output here>

Specify the base through the prefix 0b for binary, 0o for octal, 0d for decimal and 0x for hex.

$ bs 0xF
bs 0xF
[from hexadecimal]
  decimal     15
  binary      1111
  octal       17

Specifying base through a flag.

$ bs --from hex F
[from hexadecimal]
  decimal     15
  binary      1111
  octal       17

From base-36 (the maximum supported base, which uses the digits 0-9 and then a-z).

$ bs --from 36 zx1
[from base-36]
  decimal     46549
  binary      1011010111010101
  hexadecimal B5D5
  octal       132725

To base-7.

$ bs --to 7 54
[from decimal]
  base-7 105

[from hexadecimal]
  base-7 150

[from octal]
  base-7 62

Specifying both input and output bases.

$ bs --from hex --to dec F
15

Shorthand for lazy people.

$ bs -f h -t d F
15

Padding with zeroes.

$ bs --from decimal --to binary --pad 8 14

Aaaaand input through a pipe.

$ echo '5+10' | bc | bs -t h
[from decimal]
  hexadecimal F

[from octal]
  hexadecimal D

Contributing

Feel free to submit tweaks. To run tests, install tox via pip3 install tox and then run the tox command from the base directory.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

base-convert-cli-1.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

base_convert_cli-1.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file base-convert-cli-1.0.1.tar.gz.

File metadata

  • Download URL: base-convert-cli-1.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.24.0 requests-toolbelt/0.9.1 urllib3/1.25.10 tqdm/4.62.0 importlib-metadata/1.6.1 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

File hashes

Hashes for base-convert-cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a8c7b511558165709a97d076e1bbc267736d9c06e68c8e4109494f8819bf3ade
MD5 ae14645bf2bea718ffb7f8a6c73d9b19
BLAKE2b-256 9303a3da7950addee30c8e7daee4743e21a6706f697d2a6f50990709b2da583c

See more details on using hashes here.

File details

Details for the file base_convert_cli-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: base_convert_cli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.24.0 requests-toolbelt/0.9.1 urllib3/1.25.10 tqdm/4.62.0 importlib-metadata/1.6.1 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

File hashes

Hashes for base_convert_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2afd4263c08b1ea39cfcacadce19b51ea51ab1769ca3029ac50644bdd1695c4e
MD5 6d3840e87738c38c1f279652b38902cb
BLAKE2b-256 94fc3de597f650081c4ba32e483e008bf71532f2cdcf9e9d46f2bc9461c97364

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page