float32 refuses a value that should saturate to an infinity
還沒有人認領這個 Issue。
評估
研究方向
從 compact_encoding.float32 編碼器開始,重現名為 float32-overflow 的 compact-encoding-test 語料庫案例,並將其與 issue 中描述的 struct.pack 行為進行比較。完成意味著編碼 4e38 不再拋出 OverflowError,並產生參考位元組 0000807f,同時一致性案例通過。
由索引模型根據 Issue 內容生成。
描述
Found by running the compact-encoding-test conformance corpus against this port.
float32 refuses a value too large for binary32 instead of saturating to an infinity:
import compact_encoding as c
c.encode(c.float32, 4e38) # OverflowError: float too large to pack with f format
The reference writes 0000807f, which reads back as infinity. That is what IEEE 754 round-to-nearest gives when a double is narrowed to binary32 and the result is out of range, so the reference's behaviour is the standard one here rather than a quirk.
The cause looks like struct.pack surfacing rather than a decision:
import struct
struct.pack('<f', 4e38) # OverflowError: float too large to pack with f format
The corpus case is float32-overflow, citing float-overflows-to-an-infinity: "a value too large for the width becomes an infinity rather than a refusal, so float32 writes 4e38 as 0000807f and loses it. A float codec refuses no number it is given: what the width cannot hold it rounds, and what the width cannot reach becomes an infinity."
- 主要語言
- Python
- 星號
- 1
- 分支
- 1
- 平均合併
- 4 天 6 小時
- 30 天內合併 PR
- 1
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
holepunchto/compact-encoding-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
-
難度 3/5 1-2 天 新手友好度 75/100
查看 holepunchto/compact-encoding-python 的全部 Issue
相似的 Issue
-
automated issue linkchecker report
難度 2/5 1-3 小時 新手友好度 66/100
QuantEcon/lecture-python.myst#1098 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
podly-pure-podcasts/podly_pure_podcasts#279 ·
維護者通常 1 天內回覆
-
template-proposal
難度 1/5 1 小時以內 新手友好度 78/100
-
難度 1/5 1 小時以內 新手友好度 82/100
OpenShot/openshot-qt#6230 ·
維護者通常 1 天內回覆