Skip to main content

A CLI tool that converts numbers between bases.

Project description

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 --prec 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.

Project details


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.3.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

base_convert_cli-1.0.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: base-convert-cli-1.0.3.tar.gz
  • Upload date:
  • Size: 5.5 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.3.tar.gz
Algorithm Hash digest
SHA256 0c97f5b19db0f4040b3ba1a5fb29af470e831cc971d487847827ef30c3861092
MD5 3282bcf31da13ca4162c3acd381a0817
BLAKE2b-256 7609432db6908ade9c1f76aee1cd9ad42da50f2f830f60d3e9320cbab9ed24b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: base_convert_cli-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 da5661b18958ae3e418493d8c9d5ede55e370f511629ff37944aad2f74fd2387
MD5 b6e6091590bb6c7a33252cda2881cbf0
BLAKE2b-256 47dfbc00517b8b86e13c71d48232e8b80b0e50fd74daf41a04eec21fcb677cac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page