.. image:: https://img.shields.io/pypi/v/defloat.svg
:target: https://pypi.python.org/pypi/defloat
.. image:: https://img.shields.io/pypi/l/defloat
:target: https://spdx.org/licenses/MPL-2.0.html
.. image:: https://img.shields.io/pypi/pyversions/defloat.svg
:target: https://pypi.python.org/pypi/defloat
DeFloat
=======
Floating Point Decomposition
A small implementation of a portable floating point format
(i.e. with no loss of precision across floating point
implementations).
Examples
----------
..
Because GitHub doesn't support the include directive
we just copy/paste these from examples
Object-Oriented style:
.. code:: python
if __name__ == '__main__':
from defloat import DeFloat
a = 5.32515
b = b_z, b_e = DeFloat.decomp(a)
c = float(b) # 1 way to do it
d = b.recomp() # the other way to do it
print(f"decomposition: fraction={b_z}, exponent={b_e}")
print(f"recomposition 1: {c}")
print(f"recomposition 2: {d}")
print(f"check: {a}")
assert c == d == a
"""
expected output:
decomposition: fraction=5995585888922999, exponent=3
recomposition 1: 5.32515
recomposition 2: 5.32515
check: 5.32515
"""
Procedural style:
.. code:: python
if __name__ == '__main__':
import defloat
a = 5.32515
b_z, b_e = defloat.decomp(a)
c = defloat.recomp(b_z, b_e)
print(f"decomposition: fraction={b_z}, exponent={b_e}")
print(f"recomposition: {c}")
print(f"check: {a}")
assert c == a
"""
expected output:
decomposition: fraction=5995585888922999, exponent=3
recomposition: 5.32515
check: 5.32515
"""
Notes
-------
Recomposition on hardware with lower precision may/will result
in data/precision loss. Precision is only guaranteed within
the decomposed format, and recomposition to the same implementation
as decomposed from.
License
-------
`DeFloat`_ is licensed under `Mozilla Public License`_.
.. External References:
.. _DeFloat: https://github.com/technikian/defloat
.. _Mozilla Public License:
https://github.com/technikian/defloat/blob/master/LICENCE
Raw data
{
"_id": null,
"home_page": "https://github.com/technikker/defloat",
"name": "DeFloat",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, DeFloat, float, floating, point, decompose, decomposition, portable",
"author": "techniker",
"author_email": "<mail@xxxxxxxx.com>",
"download_url": "https://files.pythonhosted.org/packages/04/95/5000d767111e44cee0e247cb25699eb9eeabc45809e8f40c1135d4383be9/defloat-0.0.1.tar.gz",
"platform": null,
"description": "\r\n.. image:: https://img.shields.io/pypi/v/defloat.svg\r\n\t:target: https://pypi.python.org/pypi/defloat\r\n\r\n.. image:: https://img.shields.io/pypi/l/defloat\r\n\t:target: https://spdx.org/licenses/MPL-2.0.html\r\n\r\n.. image:: https://img.shields.io/pypi/pyversions/defloat.svg\r\n\t:target: https://pypi.python.org/pypi/defloat\r\n\r\n\r\nDeFloat\r\n=======\r\n\r\nFloating Point Decomposition\r\n\r\nA small implementation of a portable floating point format\r\n(i.e. with no loss of precision across floating point\r\nimplementations).\r\n\r\n\r\nExamples\r\n----------\r\n\r\n..\r\n\tBecause GitHub doesn't support the include directive\r\n\twe just copy/paste these from examples\r\n\r\n\r\nObject-Oriented style:\r\n\r\n.. code:: python\r\n\r\n\tif __name__ == '__main__':\r\n\t\tfrom defloat import DeFloat\r\n\r\n\t\ta = 5.32515\r\n\t\tb = b_z, b_e = DeFloat.decomp(a)\r\n\t\tc = float(b) # 1 way to do it\r\n\t\td = b.recomp() # the other way to do it\r\n\r\n\t\tprint(f\"decomposition: fraction={b_z}, exponent={b_e}\")\r\n\t\tprint(f\"recomposition 1: {c}\")\r\n\t\tprint(f\"recomposition 2: {d}\")\r\n\t\tprint(f\"check: {a}\")\r\n\r\n\t\tassert c == d == a\r\n\r\n\t\t\"\"\"\r\n\t\texpected output:\r\n\t\t\tdecomposition: fraction=5995585888922999, exponent=3\r\n\t\t\trecomposition 1: 5.32515\r\n\t\t\trecomposition 2: 5.32515\r\n\t\t\tcheck: 5.32515\r\n\t\t\"\"\"\r\n\r\n\r\nProcedural style:\r\n\r\n.. code:: python\r\n\r\n\tif __name__ == '__main__':\r\n\t\timport defloat\r\n\r\n\t\ta = 5.32515\r\n\t\tb_z, b_e = defloat.decomp(a)\r\n\t\tc = defloat.recomp(b_z, b_e)\r\n\r\n\t\tprint(f\"decomposition: fraction={b_z}, exponent={b_e}\")\r\n\t\tprint(f\"recomposition: {c}\")\r\n\t\tprint(f\"check: {a}\")\r\n\r\n\t\tassert c == a\r\n\r\n\t\t\"\"\"\r\n\t\texpected output:\r\n\t\t\tdecomposition: fraction=5995585888922999, exponent=3\r\n\t\t\trecomposition: 5.32515\r\n\t\t\tcheck: 5.32515\r\n\t\t\"\"\"\r\n\r\n\r\nNotes\r\n-------\r\n\r\nRecomposition on hardware with lower precision may/will result\r\nin data/precision loss. Precision is only guaranteed within\r\nthe decomposed format, and recomposition to the same implementation\r\nas decomposed from.\r\n\r\n\r\nLicense\r\n-------\r\n\r\n`DeFloat`_ is licensed under `Mozilla Public License`_.\r\n\r\n.. External References:\r\n.. _DeFloat: https://github.com/technikian/defloat\r\n.. _Mozilla Public License:\r\n\thttps://github.com/technikian/defloat/blob/master/LICENCE\r\n",
"bugtrack_url": null,
"license": "MPL",
"summary": "Portable Floating Point Decomposition",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/technikker/defloat",
"Source": "https://github.com/technikker/defloat"
},
"split_keywords": [
"python",
" defloat",
" float",
" floating",
" point",
" decompose",
" decomposition",
" portable"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8bfa66f7d7fcde89af9dbbcbced947a3020a6d44839dd83ed97b17a781c05c77",
"md5": "1b7f1d314cc5be17b700d892100b6e87",
"sha256": "a618a332e22eb016ceb67af725c728520a41ee339143cfdf4e5c08b260e31b96"
},
"downloads": -1,
"filename": "DeFloat-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b7f1d314cc5be17b700d892100b6e87",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8580,
"upload_time": "2024-06-14T23:55:36",
"upload_time_iso_8601": "2024-06-14T23:55:36.851222Z",
"url": "https://files.pythonhosted.org/packages/8b/fa/66f7d7fcde89af9dbbcbced947a3020a6d44839dd83ed97b17a781c05c77/DeFloat-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "04955000d767111e44cee0e247cb25699eb9eeabc45809e8f40c1135d4383be9",
"md5": "0afeaad3b3dfc402c51b3d9a14b90348",
"sha256": "db7c5a544299f35d475f2081cf7d81cb88da4425484097b81eac3453eef51f39"
},
"downloads": -1,
"filename": "defloat-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "0afeaad3b3dfc402c51b3d9a14b90348",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8918,
"upload_time": "2024-06-14T23:55:39",
"upload_time_iso_8601": "2024-06-14T23:55:39.018878Z",
"url": "https://files.pythonhosted.org/packages/04/95/5000d767111e44cee0e247cb25699eb9eeabc45809e8f40c1135d4383be9/defloat-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-14 23:55:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "technikker",
"github_project": "defloat",
"github_not_found": true,
"lcname": "defloat"
}