apytypes

Python package for custom fixed-point and floating-point formats


Keywords
fixed-point, fixed-point-arithmetic, floating-point, floating-point-arithmetic, python
License
MIT
Install
pip install apytypes==0.1.0

Documentation

APyTypes

PyPI pre-commit.ci status License Workflow Status codecov

Documentation

https://apytypes.github.io/apytypes/

Installation

APyTypes is available in the Python Package Index and can be installed with the pip package installer:

pip install apytypes

Uninstall APyTypes with:

pip uninstall apytypes

Running

The package can now be used as:

$ python3
>>> from apytypes import APyFixed
>>> fx_a = APyFixed.from_float(3.5, 8, 4)
>>> print(fx_a)
3.5
>>> fx_a
APyFixed(bit_pattern=56, bits=8, int_bits=4)
>>> fx_b = APyFixed.from_float(1.25, 9, 3)
>>> fx_a + fx_b
APyFixed(bit_pattern=304, bits=11, int_bits=5)
>>> print(fx_a + fx_b)
4.75

Tests

Test dependencies can be installed by running pip3 install [.test] and then executed by pytest.