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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python-radix-ng-0.3.linux-x86_64.tar.gz.
File metadata
- Download URL: python-radix-ng-0.3.linux-x86_64.tar.gz
- Upload date:
- Size: 3.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24fbac3bebcc2fef04d592d6465778a32075b9d3637cbe48b55a3467aa75dc31
|
|
| MD5 |
89d1a59e13ea61a5f2a0c9448c6b7e07
|
|
| BLAKE2b-256 |
16d9938fdcc549c9616a196329b4f85634e3f4fd5f910f3bcd31b8d5e2a60ad0
|
File details
Details for the file python_radix_ng-0.3-py2.py3-none-any.whl.
File metadata
- Download URL: python_radix_ng-0.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87fbc1b00d96d9156f310389590a690bf8516ccc1d3cadc6cd68b329d75e14c7
|
|
| MD5 |
67254be7afd9486a9e6a3c006d70847b
|
|
| BLAKE2b-256 |
50fd3b24bce03760edc91f008b63deb4dd888bfeb6927ca8f6105b10b208a008
|