Skip to main content

Arbitrary precision decimal numbers

A module with a simple implementation for arbitrary precision decimal numbers. The key difference to most other decimal libraries is that there is no maximum precision for example when doing divisions.

>>> from dezimal import Dezimal
>>> Dezimal("355") / Dezimal("113")
Dezimal('3.14159292035398230088495575221238938053097345132743362831858407079646017699115044247787610619469026548672566371681')

dezimal will calculate as many digits after the decimal point as there are, no ROUNDING_MODE or whatever needed.

If the calculation would result in a period, dezimal detects that and stops the calculation as needed:

>>> Dezimal("1") / Dezimal("7")
Dezimal('0.14285714285714285')

However, it prints a minimum number of digits, as to display at least the same precision as a regular float would (a bit more actually).

>>> Dezimal("1") / Dezimal("3")
Dezimal('0.33333333333333333')
>>> 1.0 / 3.0
0.3333333333333333

These parameters can be controlled by invoking the static div method in Dezimal directly:

>>> Dezimal.div(Dezimal("1"), Dezimal("3"), minscale=5)
Dezimal('0.33333')

Also a maximum precision can be given:

>>> Dezimal.div(Dezimal("355"), Dezimal("113"), maxscale=30)
Dezimal('3.141592920353982300884955752212')

Construction

An instance of Dezimal can be constructed from int, float, bool, or a str. The usual formats like 3, 3.0, 7e1, -7e-9, or +13.03e-3 are understood.

Supported operations

The following operations are supported:

+ - * / // < <= > >= == !=

Why?

For fun.

Metadata

Release files for dezimal 0.4.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 dezimal 0.4.0
File Size Uploaded Provenance Actions
dezimal-0.4.0.tar.gz 4.7 kB Without provenance Details for dezimal-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 10.6 kB

Release files / dezimal-0.4.0.tar.gz

Download URL dezimal-0.4.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f66cd7f11fab42b12ad2e59ac0061f5da355cb3bee0d6d2737c5b6a8fd8f1062
BLAKE2b-256 checksum
How to use checksums
3c18d8beb65925335a1d5d150df4ec570f1e6906cf6912ad8b2af11b06916b43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release files / dezimal-0.4.0-py3-none-any.whl

Download URL dezimal-0.4.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9dee9360aaf26903f7fbed088311a69ce5277629daf722b9c7e47d6c471fe19
BLAKE2b-256 checksum
How to use checksums
b7d5b9b90e7f35e8fb9c0c5b51137da1bef3bf4cb79259c86c303f7d9750ae30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Security for dezimal 0.4.0

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