IEEE 754 float module with bit-operation and round arithmetic support
Project description
py_ieee754
IEEE 754 float number python module with bit-operation and round arithmetic support.
Install
$ pip install py-ieee754
Note
I write this module with vibe coding, but I carefully read every line in src (except the _math <math.h> binding module, which is full of tedious binding code).
I found some bug when I review AI's code, so there might be more. Use with care. I really recommend you to check the code part you are using (usually very short). Bug report is welcomed.
Also note the terminology about "exponent" and "biased exponent":
- "exponent" means the raw exp bit pattern interpreted as a uint
- "biased exponent" means the exponent after the IEEE754 bias rule applied, i.e. (exponent - bias) for normalized float, (1 - bias) for denormalized float
Usage
>>> import py_ieee754 as pi7
>>> import ctypes as ct
>>> # Construction
>>> pi7.F32(1.5)
F32(0b0_01111111_10000000000000000000000)
>>> pi7.F64.from_components("0", "0"*11, "1"*52)# construct from sign, exp and sig bits
F64(0b0_00000000000_1111111111111111111111111111111111111111111111111111)
>>> pi7.F32.from_bits(0x3FC00000) # from bit pattern
F32(0b0_01111111_10000000000000000000000)
>>> pi7.IEEE754.from_ctypes(ct.c_float(1.5)) # auto-dispatch (→ F32)
F32(0b0_01111111_10000000000000000000000)
>>> # Field access & classification
>>> a = pi7.F32(1.5)
>>> a.sign, a.exponent, a.significand, a.bits
(0, 127, 4194304, 1069547520)
>>> a.is_nan, a.is_inf, a.is_zero, a.is_subnormal, a.is_normal
(False, False, False, False, True)
>>> # Arithmetic with rounding
>>> pi7.mul(pi7.F32(1.5), pi7.F32("0b1"), round_mode=pi7.RoundingMode.DOWNWARD)
F32(0b0_00000000_00000000000000000000001)
>>> # math.h functions with ctypes interface, round control and fenv exceptions
>>> pi7.math.sqrt(ct.c_double(2.0))
c_double(1.4142135623730951)
>>> pi7.math.fma(
ct.c_double(1.5),
pi7.F64.from_bits(1).ctypes_value,
ct.c_double(0),
round_mode=pi7.RoundingMode.DOWNWARD)
c_double(5e-324) # = bit 0b1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_ieee754-0.1.2-py3-none-win_arm64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-win_arm64.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6417fb3c0334608384f7a44e1ff92ccf5f1d708d1ad128e2d20a3d2110f94a38
|
|
| MD5 |
056b8961a4326a6fc974c31ad724cbac
|
|
| BLAKE2b-256 |
f6a8c752711476a5644a2345c0cf5aa077af89421cbe710e75fec214ed86a3ff
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-win_arm64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-win_arm64.whl -
Subject digest:
6417fb3c0334608384f7a44e1ff92ccf5f1d708d1ad128e2d20a3d2110f94a38 - Sigstore transparency entry: 1440070817
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-win_amd64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-win_amd64.whl
- Upload date:
- Size: 38.7 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f59189479f5de6221fd1c0dadbed499be64ea393eae6176b1eb481a2d3a0a5d9
|
|
| MD5 |
67dd678bc0821c7d08245a24941f050a
|
|
| BLAKE2b-256 |
f41199dc7e8f80a225c8e24335f9e111275c525f60042b6424a7fbaea980f97b
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-win_amd64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-win_amd64.whl -
Subject digest:
f59189479f5de6221fd1c0dadbed499be64ea393eae6176b1eb481a2d3a0a5d9 - Sigstore transparency entry: 1440070754
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl
- Upload date:
- Size: 40.3 kB
- Tags: Python 3, manylinux: glibc 2.31+ x86-64, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bba43dd33c8f631a3b0339e2bd51c59ca3d7281a337b442ccfb7f11738118410
|
|
| MD5 |
fd24efbe80630aa9238db521cc8e4530
|
|
| BLAKE2b-256 |
52a549252ecff6427102f463c7da57c9f601757cf8ff8c81b30fd4ebc2ef93d6
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl -
Subject digest:
bba43dd33c8f631a3b0339e2bd51c59ca3d7281a337b442ccfb7f11738118410 - Sigstore transparency entry: 1440070795
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-manylinux_2_31_aarch64.manylinux_2_34_aarch64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-manylinux_2_31_aarch64.manylinux_2_34_aarch64.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3, manylinux: glibc 2.31+ ARM64, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aef3400d1ca1132a7ab71f88a2e7d5bd797a2e741c8c96c2b7f636be1047afb
|
|
| MD5 |
339aecdeef4a418c9a36c3d0e8a97308
|
|
| BLAKE2b-256 |
4c9d2fcc3afc969e8b3f23cbf733534f4c2d78574a865d31a5fee959566bd65b
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-manylinux_2_31_aarch64.manylinux_2_34_aarch64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-manylinux_2_31_aarch64.manylinux_2_34_aarch64.whl -
Subject digest:
3aef3400d1ca1132a7ab71f88a2e7d5bd797a2e741c8c96c2b7f636be1047afb - Sigstore transparency entry: 1440070775
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 40.3 kB
- Tags: Python 3, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02fe09119bffa8489accae63960db06a372ae29518dd19d27987623e4169eaa2
|
|
| MD5 |
d0ca7129641a94c3763150ff352d5234
|
|
| BLAKE2b-256 |
49d28e6a3eccbb8565b676db74e08232f669bd159c098ced69c15209f7eba040
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
02fe09119bffa8489accae63960db06a372ae29518dd19d27987623e4169eaa2 - Sigstore transparency entry: 1440070725
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df60d6664aabe509e549970857da9729135e27715bff05f81084ed385ffe6dad
|
|
| MD5 |
464513121cd95cd4d1c68f18b9638d23
|
|
| BLAKE2b-256 |
859be663925586880d3e0ec9253a1b7c97ee29ee094db14c9f566604d55a5249
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
df60d6664aabe509e549970857da9729135e27715bff05f81084ed385ffe6dad - Sigstore transparency entry: 1440070671
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
- Upload date:
- Size: 38.3 kB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feab6db8b163f285cbceb92813bd39ace1950824997fd2a7b469f087856b3f26
|
|
| MD5 |
c8d3db6b6ad1ff861740c5787c2423ad
|
|
| BLAKE2b-256 |
cc5df63d49a482524af9c9b84a35895b502c850d7dd4709ccfbaf7ca0af3c36e
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl -
Subject digest:
feab6db8b163f285cbceb92813bd39ace1950824997fd2a7b469f087856b3f26 - Sigstore transparency entry: 1440070642
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 40.2 kB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5550009b117bc5f3a1b2e34338e53c497a797591e1e44f7641d8204ae83d2954
|
|
| MD5 |
9dc630511bc71fb99c941373752a8bcc
|
|
| BLAKE2b-256 |
d5fdbbf7219e003901b3663dc9700d818575c167716d398295ea768d3d07858b
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl -
Subject digest:
5550009b117bc5f3a1b2e34338e53c497a797591e1e44f7641d8204ae83d2954 - Sigstore transparency entry: 1440070621
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-macosx_26_0_x86_64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-macosx_26_0_x86_64.whl
- Upload date:
- Size: 35.5 kB
- Tags: Python 3, macOS 26.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1e5edf37ab90e8c178408abac67cca19b5cd5f231b353e9272917f38ee50c0c
|
|
| MD5 |
5b00b078823ad06e3d9f08f0dce20b9e
|
|
| BLAKE2b-256 |
29f2a6d012733eeef230657630af3ad7ff968c20b7ac9814b260c36febcd3bbf
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-macosx_26_0_x86_64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-macosx_26_0_x86_64.whl -
Subject digest:
b1e5edf37ab90e8c178408abac67cca19b5cd5f231b353e9272917f38ee50c0c - Sigstore transparency entry: 1440070695
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_ieee754-0.1.2-py3-none-macosx_15_0_arm64.whl.
File metadata
- Download URL: py_ieee754-0.1.2-py3-none-macosx_15_0_arm64.whl
- Upload date:
- Size: 35.8 kB
- Tags: Python 3, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db1c63eb1184286f4d2165388486cc607148c521398ba390058298be26b9911d
|
|
| MD5 |
a0b2cd083078193ca044ce194579f64c
|
|
| BLAKE2b-256 |
05cf9141c9bb634b05752d3c7343073657e8faa02a3f62c7fcda0e4f8e0988ea
|
Provenance
The following attestation bundles were made for py_ieee754-0.1.2-py3-none-macosx_15_0_arm64.whl:
Publisher:
release.yml on LXYan2333/py_ieee754
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ieee754-0.1.2-py3-none-macosx_15_0_arm64.whl -
Subject digest:
db1c63eb1184286f4d2165388486cc607148c521398ba390058298be26b9911d - Sigstore transparency entry: 1440070737
- Sigstore integration time:
-
Permalink:
LXYan2333/py_ieee754@780d9b42a369c096f63e826bdde568a136af6f2e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LXYan2333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@780d9b42a369c096f63e826bdde568a136af6f2e -
Trigger Event:
push
-
Statement type: