A library for arbitrary precision floating point arithmetic
Project description
FlexFloat
A Python library for arbitrary precision floating point arithmetic with a flexible exponent and fixed-size fraction.
Features
- Growable Exponents: Handle very large or very small numbers by dynamically adjusting the exponent size
- Fixed-Size Fractions: Maintain precision consistency with IEEE 754-compatible 52-bit fractions
- IEEE 754 Compatibility: Follows IEEE 754 double-precision format as the baseline
- Special Value Support: Handles NaN, positive/negative infinity, and zero values
- Arithmetic Operations: Addition and subtraction with proper overflow/underflow handling
Installation
pip install flexfloat
Development Installation
pip install -e ".[dev]"
Usage
from flexfloat import FlexFloat
# Create FlexFloat instances
a = FlexFloat.from_float(1.5)
b = FlexFloat.from_float(2.5)
# Perform arithmetic operations
result = a + b
print(result.to_float()) # 4.0
# Handle very large numbers
large_a = FlexFloat.from_float(1e308)
large_b = FlexFloat.from_float(1e308)
large_result = large_a + large_b
# Result has grown exponent to handle overflow
print(len(large_result.exponent)) # > 11 (grows beyond IEEE 754 standard)
Running Tests
python -m pytest tests
CI/CD and Release Process
This project uses automated CI/CD workflows for building, testing, and releasing:
Automatic Releases
When a Pull Request is merged to the main branch:
-
Version Detection: The system analyzes commit messages and PR labels to determine the version bump type:
major: Breaking changes (e.g., commit messages with "BREAKING CHANGE")minor: New features (e.g., commit messages starting with "feat:")patch: Bug fixes and other changes (default)
-
Version Update: All version references are automatically updated:
pyproject.tomlflexfloat/__init__.py
-
Automated Publishing:
- Package is built and tested
- New Git tag is created (e.g.,
v0.2.0) - GitHub Release is created with artifacts
- Package is published to PyPI
Manual Releases
You can also trigger releases manually:
- Go to the "Actions" tab in GitHub
- Select "Manual Release" workflow
- Choose the version bump type and add release notes
- Run the workflow
Version Bump Labels
Add these labels to your PRs to control version bumping:
major- For breaking changesminor- For new featurespatch- For bug fixes (default)
PyPI Setup
To enable automatic PyPI publishing, configure trusted publishing:
- Go to PyPI
- Add a trusted publisher for your GitHub repository
- Set the workflow name to
release.ymlormanual-release.yml
Development Workflow
- Create a feature branch from
main - Make your changes
- Create a Pull Request
- The CI will automatically:
- Run tests and linting
- Check version consistency
- Suggest version bump type
- Build and validate the package
- When merged, automatic release is triggered
License
MIT License
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flexfloat-0.1.2.tar.gz.
File metadata
- Download URL: flexfloat-0.1.2.tar.gz
- Upload date:
- Size: 33.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7409275ace544083748ab48be71d6e885b66a61413d78eac10e308e8e6b02cff
|
|
| MD5 |
ee39d725cf709289c1f91b38219f340c
|
|
| BLAKE2b-256 |
9b3ee5b3bd6e587ae2243a87034ae537a2684da70bb8f20ad39592c707241130
|
Provenance
The following attestation bundles were made for flexfloat-0.1.2.tar.gz:
Publisher:
manual-release.yml on ferranSanchezLlado/flexfloat-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flexfloat-0.1.2.tar.gz -
Subject digest:
7409275ace544083748ab48be71d6e885b66a61413d78eac10e308e8e6b02cff - Sigstore transparency entry: 301933770
- Sigstore integration time:
-
Permalink:
ferranSanchezLlado/flexfloat-py@9dccfcc70a8091707cd41990ddfe478bcc7778af -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ferranSanchezLlado
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
manual-release.yml@9dccfcc70a8091707cd41990ddfe478bcc7778af -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file flexfloat-0.1.2-py3-none-any.whl.
File metadata
- Download URL: flexfloat-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cbda5320bf8d1e4fcf4c66e0c721591c681cb49015cd7c3a8aa8f8655ff1169
|
|
| MD5 |
4d9eb9549c99d5a470c109fae51d7b2c
|
|
| BLAKE2b-256 |
73a41a8bfcf088dbc7e5a99a6bfefac00819a8a48dbf12235f8328817d8cc5ee
|
Provenance
The following attestation bundles were made for flexfloat-0.1.2-py3-none-any.whl:
Publisher:
manual-release.yml on ferranSanchezLlado/flexfloat-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flexfloat-0.1.2-py3-none-any.whl -
Subject digest:
3cbda5320bf8d1e4fcf4c66e0c721591c681cb49015cd7c3a8aa8f8655ff1169 - Sigstore transparency entry: 301933778
- Sigstore integration time:
-
Permalink:
ferranSanchezLlado/flexfloat-py@9dccfcc70a8091707cd41990ddfe478bcc7778af -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ferranSanchezLlado
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
manual-release.yml@9dccfcc70a8091707cd41990ddfe478bcc7778af -
Trigger Event:
workflow_dispatch
-
Statement type: