This release is a pre-release and may not be stable for production use.
RebelBase
RebelBase is a Python package for working with numbers of any base.
Full documentation is online at rebelbase.dev.
What does RebelBase do?
Want to work with base 3 numbers? We've got you covered.
from rebelbase import Base3
n = Base3(42) # Represent decimal 42 in base 3
print("n: ", n) # "1120" (Decimal 42 == base 3 1120)
print("n + 1:", n + 1) # "1121" (Decimal 42 + 1 == base 3 1121)
print("n - 1:", n - 1) # "1112" (Decimal 42 - 1 == base 3 1112)
print("n / 2:", n / 2) # "210" (Decimal 42 / 2 == base 3 210)
print("n * 2:", n * 2) # "10010" (Decimal 42 * 1 == base 3 10010)
n = Base3("212") # Create the base 3 value 212
print(int(n)) # "23" (Base 3 212 == decimal 23)
Need to make your own bonkers base 5 system with vowels for digits? No problem.
from rebelbase.number import Number
class Base5(Number):
@classmethod
def digits(cls) -> tuple[str, ...]:
return ("A", "E", "I", "O", "U")
n = Base5(42) # Represent decimal 42 in base 5
print("n: ", n) # "EOI" (Decimal 42 == base 5 EOI)
print("n + 1:", n + 1) # "EOO" (Decimal 42 + 1 == base 5 EOO)
print("n - 1:", n - 1) # "EOE" (Decimal 42 - 1 == base 5 EOE)
print("n / 2:", n / 2) # "UE" (Decimal 42 / 2 == base 5 UE)
print("n * 2:", n * 2) # "OEU" (Decimal 42 * 2 == base 5 OEU)
n = Base5("OOO") # Create the base 5 value OOO
print(int(n)) # "93" (Base 5 OOO == decimal 93)
A Number can be created with optional zero support for any base.
Numbers can be initialised with their decimal value or string representation.
A ton of Python operations -- including addition, subtraction, floor and true division, multiplication, modulo and exponentiation -- work out of the box.
Installation
RebelBase requires Python 3.9 or later.
pip install rebelbase
Support
Please raise bugs, request new features and ask questions at github.com/cariad/rebelbase/issues.
Contributions
See CONTRIBUTING.md for contribution guidelines.
The Project
RebelBase is © 2022 Cariad Eccleston and released under the MIT License at cariad/rebelbase.
The Author
Hello! 👋 I'm Cariad Eccleston and I'm a freelance backend and infrastructure engineer in the United Kingdom. You can find me at cariad.earth, github.com/cariad, linkedin.com/in/cariad and on Mastodon at @cariad@tech.lgbt.
Metadata
Release files for rebelbase 1.0.0a7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rebelbase-1.0.0a7-py3-none-any.whl | Python 3 | none | any | Details |
Release files / rebelbase-1.0.0a7-py3-none-any.whl
| Download URL | rebelbase-1.0.0a7-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc7ddceb0e449e9a460bf4a6725fe37726b8611779ff03b1a4a5fc19db7dae5c
|
|
BLAKE2b-256 checksum How to use checksums |
7d33fde56790217c141601272dea1221285ec1900a5d80b5e7e85c9cdcccfe8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|