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
00001110

Setting precision for converting fractional numbers.

$ bs --precision 10 --from 3 --to decimal 0.1
0.3333333333

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.2.tar.gz (5.3 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.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: base-convert-cli-1.0.2.tar.gz
  • Upload date:
  • Size: 5.3 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.2.tar.gz
Algorithm Hash digest
SHA256 b9a38fac85c21927f4d344ab3ea751da9392ae0c03713752648558d13f34a0a9
MD5 accccc7e4a14681fbded95e070feadb1
BLAKE2b-256 613f74bda1e88db3a011902b6b202ae4807042e9b19d6ebcebd328330b415faa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: base_convert_cli-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 44ba344bc3af0cecb05765d81ecfbadd55cfeac73304f30c9a22fddca23cb8ae
MD5 776d9efa04454810cee258f862286546
BLAKE2b-256 690d9bb2682a7ed3b0f20872f83152a6f32138ddc190cf5056af42c005893db2

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 Pingdom Monitoring Sentry Error logging StatusPage Status page