Skip to main content

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:

  1. 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)
  2. Version Update: All version references are automatically updated:

    • pyproject.toml
    • flexfloat/__init__.py
  3. 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:

  1. Go to the "Actions" tab in GitHub
  2. Select "Manual Release" workflow
  3. Choose the version bump type and add release notes
  4. Run the workflow

Version Bump Labels

Add these labels to your PRs to control version bumping:

  • major - For breaking changes
  • minor - For new features
  • patch - For bug fixes (default)

PyPI Setup

To enable automatic PyPI publishing, configure trusted publishing:

  1. Go to PyPI
  2. Add a trusted publisher for your GitHub repository
  3. Set the workflow name to release.yml or manual-release.yml

Development Workflow

  1. Create a feature branch from main
  2. Make your changes
  3. Create a Pull Request
  4. The CI will automatically:
    • Run tests and linting
    • Check version consistency
    • Suggest version bump type
    • Build and validate the package
  5. When merged, automatic release is triggered

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flexfloat-0.1.2.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flexfloat-0.1.2-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

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

Hashes for flexfloat-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7409275ace544083748ab48be71d6e885b66a61413d78eac10e308e8e6b02cff
MD5 ee39d725cf709289c1f91b38219f340c
BLAKE2b-256 9b3ee5b3bd6e587ae2243a87034ae537a2684da70bb8f20ad39592c707241130

See more details on using hashes here.

Provenance

The following attestation bundles were made for flexfloat-0.1.2.tar.gz:

Publisher: manual-release.yml on ferranSanchezLlado/flexfloat-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for flexfloat-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3cbda5320bf8d1e4fcf4c66e0c721591c681cb49015cd7c3a8aa8f8655ff1169
MD5 4d9eb9549c99d5a470c109fae51d7b2c
BLAKE2b-256 73a41a8bfcf088dbc7e5a99a6bfefac00819a8a48dbf12235f8328817d8cc5ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for flexfloat-0.1.2-py3-none-any.whl:

Publisher: manual-release.yml on ferranSanchezLlado/flexfloat-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page