Skip to main content

digint

Base-Agnostic Integer Manipulation

digint is a module focused on easy high-level integer manipulation across any numerical base. Works with binary, decimal, or any other base. digint seeks to make complex digit-level and notation operations easy, just like they were Collections.

Documentation

Setup

This module can be installed using:

pip install digint

Usage

This module is intended to be used only as a module, and can be imported after installing using the traditional process:

from digint import digitint

Create an integer in any base

# input integers as you would with `int()`,
# if the intiger is already in the base you wish to use
n1 = digitint(1234, base=10)
n2 = digitint("BASE36", base=36)
n3 = digitint(0xABCDEF, base=16)

# convert bases on initialization, if the input is a intiger type
n4 = digitint(255, base=2) # == 0b11111111
n5 = digitint(int("BASE36", 36), base=10) # == 683248722
n6 = digitint(0xABCDEF, base=10) # == 11259375

Access and modify digits like a collection

# get the digit at index 2
print(n1.get_digit(2)) # outputs "3"
num.set_digit(2, 5)
print(n1.get_digit(2)) # outputs "5"

Easy notation

print(str(n2)) # output "BASE36"
print(str(n3)) # output "ABCDEF"
print(str(n5)) # output "683248722", as the base is set to 10

Full mutable collection implementation on integers

print(n2.pop(-1)) #outputs "6"
print(n2.pop(-1)) #outputs "3"
n2.append(int("D", 36))
print(n2) #outputs "BASED"

# The sum of all digits
print(sum(n2)) #outputs "76"

# The average of all digits
print(sum(n2)/len(n2)) #outputs "15.2"

Customizable Notation

# same as str(n3) 
print(n3.notate()) # outputs "ABCDEF"

from digint import NotationFormat
fmt = NotationFormat(*tuple("0123456789ZYXWVU"))
print(n3.notate(fmt)) # outputs "ZYXWVU"

And More

There are a handfull of other ease of use features that this module provides, feel free to reference the documentation for more information.

Licence

This is licensed under the Mozilla Public License 2.0 (MPL 2.0) Licence. See the Licence file in this repository for more information.

Contribute

Contributions are always welcome! Use the github repository to report issues and contribute to this project.

Credits

While not required, feel free to credit "Markus Hammer" (or just "Markus") if you find this code or script useful for whatever you may be doing with it.

Security Policy

While the python source code will be actively maintained, any binary files (if at all provided) are in no way supported. These are provided as a courtesy and are not intended to be the main usage of this software. Please keep this in mind when choosing how you wish to use this software.

Supported Versions

Version Supported
1.0.0.0 >= ✅
1.0.0.0 < ❌

Reporting a Vulnerability

Please report any issues to the email 107761433+MarkusHammer(THEN THE @ SYMBOL HERE)users.noreply.github.com

Metadata

Release files for digint 1.0.3.0

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

Source distribution (sdist)

Source distribution for digint 1.0.3.0
File Size Uploaded
digint-1.0.3.0.tar.gz 24.8 kB Details

Built distribution (wheel)

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

Total release size: 49.0 kB

Release files / digint-1.0.3.0.tar.gz

Download URL digint-1.0.3.0.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
03dbccda62ee7a22683c14dcdbf6f50debcba58ee045bfe6516c64e938bb8294
BLAKE2b-256 checksum
How to use checksums
fd86e833cdfa17ddf246d4ed17347b0c01e0d640dd2f44b34b46105796101350
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release files / digint-1.0.3.0-py3-none-any.whl

Download URL digint-1.0.3.0-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49fd1cc07678d96d859c8396846e345758d404f7b205b161937178a454470f2f
BLAKE2b-256 checksum
How to use checksums
fffd659537ad8fa8e074ff962423ef8e6e975dfea51efc96c8c3d2ba574801cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.0.3.0 This release

2 release files

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