FlexFloat 1.0.0 Documentation๏ƒ

Python 3.11+ License: MIT PyPI version

Welcome to FlexFloat 1.0.0, a high-precision Python library for arbitrary precision floating-point arithmetic with growable exponents and fixed-size fractions.

FlexFloat extends IEEE 754 double-precision format to handle numbers beyond the standard range while maintaining computational efficiency and precision consistency.

โœจ Key Features๏ƒ

  • ๐Ÿ”ข Growable Exponents: Dynamically expand exponent size to handle extremely large (>10^308) or small (<10^-308) numbers

  • ๐ŸŽฏ Fixed-Size Fractions: Maintain IEEE 754-compatible 52-bit fraction precision for consistent accuracy

  • โšก Full Arithmetic Support: Addition, subtraction, multiplication, division, and power operations

  • ๐Ÿ“ Complete Math Library: Comprehensive mathematical functions including trigonometric, logarithmic, exponential, and hyperbolic functions

  • ๐Ÿ”ง Multiple BitArray Backends: Choose between bool-list, int64-list, and big-integer implementations for optimal performance

  • ๐ŸŒŸ Special Value Handling: Complete support for NaN, ยฑinfinity, and zero values

  • ๐Ÿ›ก๏ธ Overflow Protection: Automatic exponent growth prevents overflow/underflow errors

  • ๐Ÿ“Š IEEE 754 Baseline: Fully compatible with standard double-precision format as the starting point

๐Ÿš€ Quick Start๏ƒ

Installation๏ƒ

pip install flexfloat

Basic Usage๏ƒ

from flexfloat import FlexFloat
from flexfloat.math import sin, cos, pi, exp, log

# Create FlexFloat numbers
x = FlexFloat.from_float(1.5)
y = FlexFloat.from_float(2.5)

# Basic arithmetic
result = x + y
print(result.to_float())  # 4.0

# Mathematical functions
angle = pi / FlexFloat.from_float(4.0)  # ฯ€/4 radians
sin_result = sin(angle)  # sin(45ยฐ) โ‰ˆ 0.707

# Exponential and logarithmic functions
exp_result = exp(x)      # e^1.5
log_result = log(y)      # ln(2.5)

# Handle very large numbers that would overflow standard floats
large_a = FlexFloat.from_float(1e308)
large_b = FlexFloat.from_float(1e308)
large_result = large_a + large_b  # No overflow!

Mathematical Functions๏ƒ

FlexFloat 1.0.0 includes a comprehensive mathematical function library:

from flexfloat.math import *

# Trigonometric functions
sin(x), cos(x), tan(x)
asin(x), acos(x), atan(x), atan2(y, x)

# Exponential and logarithmic functions
exp(x), expm1(x), pow(x, y)
log(x), log10(x), log2(x), log1p(x)

# Hyperbolic functions
sinh(x), cosh(x), tanh(x)
asinh(x), acosh(x), atanh(x)

# Square root functions
sqrt(x), cbrt(x)

# Mathematical constants
pi, e, tau, inf, nan

# Utility functions
ceil(x), floor(x), fabs(x), fmod(x, y)

๐Ÿ“š Table of Contents๏ƒ

๐Ÿ“– API Documentation๏ƒ

Core Classes๏ƒ

flexfloat.FlexFloat([sign,ย exponent,ย fraction])

A class to represent a floating-point number with growable exponent and fixed-size fraction.

BitArray Implementations๏ƒ

flexfloat.BitArray(*args,ย **kwargs)

Protocol defining the interface for BitArray implementations.

flexfloat.ListBoolBitArray([bits])

A bit array class that encapsulates a list of booleans with utility methods.

flexfloat.ListInt64BitArray([chunks,ย length])

A memory-efficient bit array class using a list of int64 values.

flexfloat.BigIntBitArray([value,ย length])

A memory-efficient bit array class using Python's infinite-size int.

Math Functions๏ƒ

flexfloat.math

flexfloat.math - Mathematical Functions for FlexFloat

๐Ÿ”— Indices and Tables๏ƒ

๐Ÿค Contributing๏ƒ

We welcome contributions! Please see our Contributing Guide for details on how to get started.

๐Ÿ“„ License๏ƒ

This project is licensed under the MIT License - see the License file for details.

๐Ÿ’ฌ Support๏ƒ

If you encounter any issues or have questions, please:

  1. Check the documentation

  2. Search existing GitHub issues

  3. Create a new issue if needed

๐Ÿ“Š Version Information๏ƒ

This documentation is for FlexFloat version 1.0.