Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

float32 refuses a value that should saturate to an infinity

未關閉 適合新手
#19 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
75/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
python
領域
backend

研究方向

從 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,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

holepunchto/compact-encoding-python 的其他 Issue

查看 holepunchto/compact-encoding-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。