Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

float32 refuses a value that should saturate to an infinity

オープン 初心者向け
#19 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

holepunchto/compact-encoding-python のほかの issue

holepunchto/compact-encoding-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。