Recruit numbers to any base
Project description
RebelBase
RebelBase is a Python package for working with numbers of different bases.
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
# Create the base 3 value of decimal 42:
n = Base3(42)
print("n: ", n) # 1120
print("n + 1:", n + 1) # 1121
print("n - 1:", n - 1) # 1112
print("n / 2:", n / 2) # 210
print("n * 2:", n * 2) # 10010
# Create the base 3 value 212:
n = Base3("212")
print(int(n)) # 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")
# Create the base 5 value of decimal 42:
n = Base5(42)
print("n: ", n) # EOI
print("n + 1:", n + 1) # EOO
print("n - 1:", n - 1) # EOE
print("n / 2:", n / 2) # UE
print("n * 2:", n * 2) # OEU
# Create the base 5 value OOO:
n = Base5("OOO")
print(int(n)) # 93
A rebelbase.Number
can be created with optional zero support for any base.
Numbers can be initialised with their decimal value or string representation.
Support for a ton of Python operations -- including addition, subtraction, floor and true division, multiplication, modulo and exponentiation -- works 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.
In a nutshell: bugs and feature requests are gratefully received at github.com/cariad/rebelbase/issues and I don't accept unplanned pull requests.
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.
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 Distributions
Built Distribution
Hashes for rebelbase-1.0.0a4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dbc01c69c09856f115eeeb2c813f5f90b7f8c8b91aadcb86d58ee3c4490b4a5 |
|
MD5 | 1db1604a41d8f5eedd4738cb22dfff3c |
|
BLAKE2b-256 | d4d4489734be93850de121b27c4f4671cd2638c0c80dc153bddb285e5c4379ff |