Skip to main content

A tool for converting numbers from one base to another, TheTechRobo edition

Project description

python-radix library

The library contains tools for representing natural numbers in a given base, or to current any numeral representing a natural number between two bases. Currently any base between 2 and 36 is supported.

Python-radix usage examples

Python-radix has both procedural and object-oriented solutions.

Procedural way example

# to convert numeral 4 from base 10 to base 2
>>> cast('4', 10, 2)
'100'

# to convert the integer 4 to base 2
>>> cast(4, None, 2)

Note that since the first argument is a number, rather than a numeral, the second parameter is irrelevant, so None is used.

Object oriented way example

>>> # create an object to find the base 2 representation of any natural number
>>> new = Converter(None, 2)
>>> new.convert(4)
'100'
>>> # create an object to find the base 2 representation of any base 10 numeral
>>> new = Converter(10, 2)

>>> new.convert('4')
'100'

Using characters as digits

# the digits 0 through 9 are succeeded by the lower case ASCII alphabet
>>> cast('a', 16, 10)
'10'

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

python-radix-ng-0.3.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

python_radix_ng-0.3.1-py2.py3-none-any.whl (3.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file python-radix-ng-0.3.1.tar.gz.

File metadata

  • Download URL: python-radix-ng-0.3.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for python-radix-ng-0.3.1.tar.gz
Algorithm Hash digest
SHA256 25c2ee0a77bfbda4d403b1d36c9998d7ae71143f485689906c4ec512e98c81d1
MD5 783cb6ab15e9df90e084c49b5e36d7dc
BLAKE2b-256 4462ae5a042422db8370bc013aaf25d39d5fcd5a3657991b610b5712c743377d

See more details on using hashes here.

File details

Details for the file python_radix_ng-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: python_radix_ng-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for python_radix_ng-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 59127932cd9156efb36ada52d84fa34253eeb235b08f035d597d2d5ab4f7d159
MD5 f475c511627f48991a3261d5f864da77
BLAKE2b-256 d00cfc2f9de83552917445f7cdaeb21dae9c710bd32fc26f9a25f055e5b17b47

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