Skip to main content

baseconvert

Convert rational numbers between positive integer bases, with exact arithmetic and recurring fractional digits.

Requires Python 3.10 or newer.

Install

Install the library from PyPI:

python -m pip install baseconvert

For the GUI, install the optional dependencies and launch the application:

python -m pip install 'baseconvert[gui]'
baseconvert

Run from a source checkout

Install just, clone the repository, and run just launch. The recipe creates .venv and installs the GUI extra if the launcher or PySide6 QML module is missing, then starts the GUI:

git clone https://github.com/BreadMakesYouFull/baseconvert.git
cd baseconvert
just launch

Development recipes

Run these recipes from the repository root:

just install       # editable install in .venv
just install-gui   # editable install with GUI dependencies
just install-dev   # install build, Black, and Twine
just format        # format Python source
just lint          # check formatting
just test          # run doctests
just check         # lint, doctests, then check files already in dist/
just build         # clean, install development tools, build sdist and wheel
just clean         # remove build artifacts AND .venv

just build first runs just clean, which also deletes .venv, and then installs the build tools again. just check does not build distributions; it runs twine check dist/* against files already in dist/. just publish-test and just publish run just check and upload the existing dist/* files to TestPyPI or PyPI, respectively. To build and validate distributions before publishing, run just build followed by just check and review the files in dist/.

Python library

The API accepts strings, digit tuples, integers, floats, and fractions.Fraction values. Use strings or Fraction to express exact decimal values without float representation concerns:

from baseconvert import base

base("FF0.8", 16, 10, string=True)  # '4080.5'
base("4080.5", 10, 16, string=True)  # 'FF0.8'
base("-0.1", 3, 10, string=True, exact=True)  # '-0.[3]'

The command-line interface reads a number argument or standard input. Bases are integers; -s prints a string, and --no-recurring disables recurring notation:

python -m baseconvert -n 4080.5 -i 10 -o 16 -s
echo 0.1 | python -m baseconvert -i 3 -o 10 --no-recurring -s

Digits, recurring fractions, and precision

String digits are 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. Values above 61 use ascending Unicode characters; tuple representation is recommended for bases above 61. In a digit tuple, each digit is a base-10 integer and the radix point is '.'. A leading '-' represents a negative value.

Recurring digits are enclosed in square brackets, for example 0.[3]. max_depth limits fractional digits (default 10). Set exact=True or max_depth=0 to calculate the complete terminating or repeating expansion when recurring output is enabled. Exact recurring detection uses rational remainders. With recurring output disabled, an unlimited expansion is bounded by MAX_DEPTH.

Metadata

Release files for baseconvert 2.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for baseconvert 2.1.1
File Size Uploaded Provenance Actions
baseconvert-2.1.1.tar.gz 19.2 kB Without provenance Details for baseconvert-2.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for baseconvert 2.1.1
File Interpreter ABI Platform Actions
baseconvert-2.1.1-py3-none-any.whl Python 3 none any Details for baseconvert-2.1.1-py3-none-any.whl

Total release size: 34.4 kB

Release files / baseconvert-2.1.1.tar.gz

Download URL baseconvert-2.1.1.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fe367bab429e66cb215ab3cd496e96d87af1b2cba1e7508cafa9a18dd8fb4065
BLAKE2b-256 checksum
How to use checksums
41d3a6ab20ff1cf4ab6d72f095701ea14485b5c94bc2fa1748ea013bc5407398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / baseconvert-2.1.1-py3-none-any.whl

Download URL baseconvert-2.1.1-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4361162fe009f0ced35ed4c4cf97103f70b94eb1b6b26c8b96ed8e3b87b890d
BLAKE2b-256 checksum
How to use checksums
221e8621bc9bf3788a9fa141311b98db3b9167865d5812964d230131cb4c78dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for baseconvert 2.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page