A Python library for fractional fixed-point (base 2) arithmetic and binary manipulation with NumPy compatibility. Current version 0.4.10 (latest stable), released roughly every few months. Supports Python >=3.7. Widely used in digital signal processing and hardware emulation contexts.
pip install fxpmathVerified import paths — ran on the pinned version, not inferred.
Create two fixed-point numbers with 8-bit word length and 7 fractional bits, add them, and show the result.
Always pass explicit fixed-point format arguments: Fxp(value, signed=True, n_word=16, n_frac=8). Use config.overflow='wrap' or 'saturate' to control behavior.
Set fxpmath.config.op_input_size = 'consistent' to require identical formats, or explicitly manage operand formats.
Set config.n_word_max to a higher value if you need >64 bits, or use the `Fxp` constructor with explicit word lengths rather than relying on wrap. Check the wrap utility documentation.
Use `Fxp.from_bin(binary_string, ...)` for binary string input. Update to fxpmath >=0.4.9.
Use `Fxp.from_bin('01010110', ...)` which handles spaces and proper parsing.Set `fxpmath.config.n_word_max = 128` (or required size) before creation.
Convert float to Fxp first: `float_val = Fxp(2.5, signed=True, n_word=8, n_frac=4)` then add.