flexfloat.BigIntBitArray
- class flexfloat.BigIntBitArray(value=0, length=0)[source]
A memory-efficient bit array class using Python’s infinite-size int.
This implementation stores all bits as a single Python integer, leveraging Python’s arbitrary precision arithmetic for potentially unlimited size. Since Python integers are arbitrary precision, this can handle bit arrays of any size limited only by available memory.
- __init__(value=0, length=0)[source]
Initializes a BigIntBitArray.
- Parameters:
- Raises:
ValueError – If length is negative.
- classmethod from_bits(bits=None)[source]
Creates a BitArray from a list of boolean values.
- Parameters:
bits (
list[bool] | None
, optional) – List of boolean values. Defaults to None, which creates an empty BitArray.- Returns:
A BitArray created from the bits.
- Return type:
- classmethod zeros(length)[source]
Creates a BitArray filled with zeros.
- Parameters:
length (
int
) – The length of the bit array.- Returns:
A BitArray filled with False values.
- Return type:
- classmethod ones(length)[source]
Creates a BitArray filled with ones.
- Parameters:
length (
int
) – The length of the bit array.- Returns:
A BitArray filled with True values.
- Return type:
- to_float()[source]
Converts a 64-bit array to a floating-point number (LSB-first).
- Returns:
The floating-point number represented by the bit array.
- Return type:
- Raises:
AssertionError – If the bit array is not 64 bits long.
- to_int()[source]
Converts the bit array to an unsigned integer (LSB-first).
- Returns:
The integer represented by the bit array.
- Return type:
- copy()[source]
Creates a copy of the bit array.
- Returns:
A new BitArray with the same bits.
- Return type:
- __len__()[source]
Returns the length of the bit array.
- Returns:
The number of bits in the array.
- Return type:
- __getitem__(index: int) bool [source]
- __getitem__(index: slice) BigIntBitArray
Gets an item or slice from the bit array.
- Parameters:
- Returns:
The bit value or a new BitArray for the slice.
- Return type:
- __setitem__(index: int, value: bool) None [source]
- __setitem__(index: slice, value: BitArray | list[bool]) None
Sets an item or slice in the bit array.
- __add__(other)[source]
Concatenates two bit arrays.