{"id":20447910,"url":"https://github.com/xman/sgpositpy","last_synced_at":"2025-04-13T01:11:02.280Z","repository":{"id":57466108,"uuid":"116416770","full_name":"xman/sgpositpy","owner":"xman","description":"Probably correct posit prototype for python","archived":false,"fork":false,"pushed_at":"2019-11-23T10:28:15.000Z","size":112,"stargazers_count":17,"open_issues_count":5,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-26T19:03:59.690Z","etag":null,"topics":["posit","python","unum"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xman.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-05T18:53:35.000Z","updated_at":"2024-04-05T06:04:39.000Z","dependencies_parsed_at":"2022-08-31T03:23:20.611Z","dependency_job_id":null,"html_url":"https://github.com/xman/sgpositpy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xman%2Fsgpositpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xman%2Fsgpositpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xman%2Fsgpositpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xman%2Fsgpositpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xman","download_url":"https://codeload.github.com/xman/sgpositpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650750,"owners_count":21139681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["posit","python","unum"],"created_at":"2024-11-15T10:30:30.984Z","updated_at":"2025-04-13T01:11:02.258Z","avatar_url":"https://github.com/xman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"sgpositpy\n=========\n.. image:: https://badges.gitter.im/sgpositpy/Lobby.svg\n   :alt: Join the chat at https://gitter.im/sgpositpy/Lobby\n   :target: https://gitter.im/sgpositpy/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge\n\n.. image:: https://travis-ci.org/xman/sgpositpy.svg?branch=master\n   :alt: sgpositpy regression test status on Travis CI\n   :target: https://travis-ci.org/xman/sgpositpy\n\n.. image:: https://ci.appveyor.com/api/projects/status/3t1q732w1cf4somj/branch/master?svg=true\n   :alt: sgpositpy regression test status on Appveyor\n   :target: https://ci.appveyor.com/project/xman/sgpositpy\n\n.. image:: https://img.shields.io/badge/License-MIT-yellow.svg\n   :alt: sgpositpy under MIT license\n   :target: https://github.com/xman/sgpositpy/blob/master/LICENSE\n\nPosit is a new binary format for representing decimal numbers, an alternative to\nIEEE 754 floating-point number. Different configurations on the number bit size\nand the scaling are possible. Details can be found at the posithub_ and the\n`notebook on posit`_.\n\nWe are interested to experiment with different posit configurations the `nbits`\nand the `es` sizes, and attempt to use smaller bit sizes in our applications\nwhile achieving the required accuracy to operate. However, an implementation\nconforming to the posit design is still lacking for popular programming\nlanguages.\n\nThis project, *sgpositpy*, is our attempt to develop a prototype implementation\nthat is correct by the posit design. This can then serve as a reference for\nsubsequent development of performance optimized posit library. Hence, the\ncomputation efficiency is currently not the focus of the project.\n\n.. _posithub: https://posithub.org\n.. _notebook on posit: https://posithub.org/docs/Posits4.pdf\n\n\nCurrent status\n==============\nThe current implementation is research oriented and experimental at pre-alpha stage.\nThis is **NOT** currently suitable for production use.\n\n\nInstall\n=======\nInstall from PyPI\n\n.. code:: bash\n\n    $ pip install sgposit\n\n\nInstall from code repository\n\n.. code:: bash\n\n    $ git clone https://github.com/xman/sgpositpy\n    $ cd sgpositpy\n    $ pip install -r requirements.txt\n    $ python setup.py install\n\n    # Run regression tests.\n    $ python setup.py test\n\n    # Enable long running tests.\n    $ SGPOSIT_LONG_TESTS=1 python setup.py test\n\n\nGetting started\n===============\nThe `PCPosit` class is our reference implementation with extensive regression\ntests. We shall have performance optimized version in `Posit` class for general\nuse in the future.\n\nThe following code snippet creates posit objects from the given bit patterns,\nand the posit configuration, `nbits` and `es`.\n\n.. code:: python\n\n    # file: samples/pcposit_sample.py\n\n    from sgposit.pcposit import PCPosit\n\n    a = PCPosit(0x0C, mode='bits', nbits=6, es=2)\n    b = PCPosit(0x0F, mode='bits', nbits=6, es=2)\n\n    c = a + b\n    print(\"{} + {} =\u003e {}\".format(a, b, c))\n\n    d = a - b\n    print(\"{} - {} =\u003e {}\".format(a, b, d))\n\n    e = a * b\n    print(\"{} * {} =\u003e {}\".format(a, b, e))\n\n    f = a / b\n    print(\"{} + {} =\u003e {}\".format(a, b, f))\n\n    g = -a\n    print(\"uminus {} =\u003e {}\".format(a, g))\n\n\n.. code:: bash\n\n    $ python samples/pcposit_sample.py\n    1/4 + 3/4 =\u003e 1\n    1/4 - 3/4 =\u003e -1/2\n    1/4 * 3/4 =\u003e 3/16\n    1/4 / 3/4 =\u003e 3/8\n    uminus 1/4 =\u003e -1/4\n\n\nLicense\n=======\n*sgpositpy* is licensed under MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxman%2Fsgpositpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxman%2Fsgpositpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxman%2Fsgpositpy/lists"}