digint


Namedigint JSON
Version 1.0.2.0 PyPI version JSON
download
home_pageNone
SummaryA python module for manipulating positional integers across any numerical base, providing advanced digit-level control.
upload_time2024-09-24 17:04:58
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords integer digit digitwise bitwise manipulation number numeric numerical bases positional number systems mathematics binary hexadecimal custom notation
VCS
bugtrack_url
requirements typing_extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `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 `Collection`s.

[Documentation](https://MarkusHammer.github.io/digint)

## Setup

This module can be installed using:

```bash
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:

```python
from digint import digitint
```

### Create an integer in any base

```python
# 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

```python
# 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

```python
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

```python
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

```python
# 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](https://MarkusHammer.github.io/digint) 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](https://github.com/MarkusHammer/digint) 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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "digint",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "integer, digit, digitwise, bitwise, manipulation, number, numeric, numerical, bases, positional, number systems, mathematics, binary, hexadecimal, custom, notation",
    "author": null,
    "author_email": "Markus Hammer <107761433+MarkusHammer@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/b3/6c/86e71eae88f4cf0b56765526722e93fe6a269519cda8e41e20283abd411d/digint-1.0.2.0.tar.gz",
    "platform": null,
    "description": "# `digint`\r\n\r\n> Base-Agnostic Integer Manipulation\r\n\r\n`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 `Collection`s.\r\n\r\n[Documentation](https://MarkusHammer.github.io/digint)\r\n\r\n## Setup\r\n\r\nThis module can be installed using:\r\n\r\n```bash\r\npip install digint\r\n```\r\n\r\n## Usage\r\n\r\nThis module is intended to be used only as a module, and can be imported after installing using the traditional process:\r\n\r\n```python\r\nfrom digint import digitint\r\n```\r\n\r\n### Create an integer in any base\r\n\r\n```python\r\n# input integers as you would with `int()`,\r\n# if the intiger is already in the base you wish to use\r\nn1 = digitint(1234, base=10)\r\nn2 = digitint(\"BASE36\", base=36)\r\nn3 = digitint(0xABCDEF, base=16)\r\n\r\n# convert bases on initialization, if the input is a intiger type\r\nn4 = digitint(255, base=2) # == 0b11111111\r\nn5 = digitint(int(\"BASE36\", 36), base=10) # == 683248722\r\nn6 = digitint(0xABCDEF, base=10) # == 11259375\r\n```\r\n\r\n### Access and modify digits like a collection\r\n\r\n```python\r\n# get the digit at index 2\r\nprint(n1.get_digit(2)) # outputs \"3\"\r\nnum.set_digit(2, 5)\r\nprint(n1.get_digit(2)) # outputs \"5\"\r\n```\r\n\r\n### Easy notation\r\n\r\n```python\r\nprint(str(n2)) # output \"BASE36\"\r\nprint(str(n3)) # output \"ABCDEF\"\r\nprint(str(n5)) # output \"683248722\", as the base is set to 10\r\n```\r\n\r\n### Full mutable collection implementation on integers\r\n\r\n```python\r\nprint(n2.pop(-1)) #outputs \"6\"\r\nprint(n2.pop(-1)) #outputs \"3\"\r\nn2.append(int(\"D\", 36))\r\nprint(n2) #outputs \"BASED\"\r\n\r\n# The sum of all digits\r\nprint(sum(n2)) #outputs \"76\"\r\n\r\n# The average of all digits\r\nprint(sum(n2)/len(n2)) #outputs \"15.2\"\r\n```\r\n\r\n### Customizable Notation\r\n\r\n```python\r\n# same as str(n3) \r\nprint(n3.notate()) # outputs \"ABCDEF\"\r\n\r\nfrom digint import NotationFormat\r\nfmt = NotationFormat(*tuple(\"0123456789ZYXWVU\"))\r\nprint(n3.notate(fmt)) # outputs \"ZYXWVU\"\r\n```\r\n\r\n### And More\r\n\r\nThere are a handfull of other ease of use features that this module provides, feel free to reference the [documentation](https://MarkusHammer.github.io/digint) for more information.\r\n\r\n## Licence\r\n\r\nThis is licensed under the Mozilla Public License 2.0 (MPL 2.0) Licence. See the Licence file in this repository for more information.\r\n\r\n## Contribute\r\n\r\nContributions are always welcome!\r\nUse the [github repository](https://github.com/MarkusHammer/digint) to report issues and contribute to this project.\r\n\r\n## Credits\r\n\r\nWhile 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.\r\n\r\n# Security Policy\r\n\r\nWhile the python source code will be actively maintained, any binary files (if at all provided) are in no way supported.\r\nThese are provided as a courtesy and are not intended to be the main usage of this software.\r\nPlease keep this in mind when choosing how you wish to use this software.\r\n\r\n## Supported Versions\r\n\r\n| Version     | Supported |\r\n| ----------- | --------- |\r\n| 1.0.0.0\u00a0>= | \u2705        |\r\n| 1.0.0.0\u00a0<  | \u274c        |\r\n\r\n## Reporting a Vulnerability\r\n\r\nPlease report any issues to the email 107761433+MarkusHammer(THEN THE @ SYMBOL HERE)users.noreply.github.com\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A python module for manipulating positional integers across any numerical base, providing advanced digit-level control.",
    "version": "1.0.2.0",
    "project_urls": {
        "Documentation": "https://MarkusHammer.github.io/digint",
        "Git": "https://github.com/MarkusHammer/digint.git",
        "Github": "https://github.com/MarkusHammer/digint",
        "Homepage": "https://github.com/MarkusHammer/digint",
        "Issues": "https://github.com/MarkusHammer/digint/issues",
        "Pull Requests": "https://github.com/MarkusHammer/digint/pulls"
    },
    "split_keywords": [
        "integer",
        " digit",
        " digitwise",
        " bitwise",
        " manipulation",
        " number",
        " numeric",
        " numerical",
        " bases",
        " positional",
        " number systems",
        " mathematics",
        " binary",
        " hexadecimal",
        " custom",
        " notation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c6b03a15478b169b41284fc3c58f33000f2bce9982acc708fdac16379408056",
                "md5": "bbc9f6f3764c0898b2bc2ce95c9a6774",
                "sha256": "8935c4d4e562908c94d50b5baad35522482ca2cf45ab7e101e97fb4f5b7b396a"
            },
            "downloads": -1,
            "filename": "digint-1.0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bbc9f6f3764c0898b2bc2ce95c9a6774",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 23343,
            "upload_time": "2024-09-24T17:04:56",
            "upload_time_iso_8601": "2024-09-24T17:04:56.822145Z",
            "url": "https://files.pythonhosted.org/packages/6c/6b/03a15478b169b41284fc3c58f33000f2bce9982acc708fdac16379408056/digint-1.0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b36c86e71eae88f4cf0b56765526722e93fe6a269519cda8e41e20283abd411d",
                "md5": "ca3ea7909f81f4580449cb6320e80f60",
                "sha256": "47aac3c1ae6e064ec82ed6f12e7c6a7f8f868d7fb0bca44ce6e79c555d7e0de0"
            },
            "downloads": -1,
            "filename": "digint-1.0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ca3ea7909f81f4580449cb6320e80f60",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 23921,
            "upload_time": "2024-09-24T17:04:58",
            "upload_time_iso_8601": "2024-09-24T17:04:58.200575Z",
            "url": "https://files.pythonhosted.org/packages/b3/6c/86e71eae88f4cf0b56765526722e93fe6a269519cda8e41e20283abd411d/digint-1.0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-24 17:04:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MarkusHammer",
    "github_project": "digint",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "typing_extensions",
            "specs": [
                [
                    ">=",
                    "3.10.0.0"
                ]
            ]
        }
    ],
    "lcname": "digint"
}
        
Elapsed time: 0.73570s