max/min return wrong value if signed (negative) zero
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
https://3v4l.org/JXU4T#v8.4.13
<?php
var_dump( min( round( -0.01 / 2, 0 ), 0 ) );
var_dump( max( round( -0.01 / 2, 0 ), 0 ) );
Resulted in this output:
int(0)
float(-0)
But I expected this output instead:
float(-0)
int(0)
For 99.9% of applications, this output is actually what people would expect however: (instead of -0)
float(0)
int(0)
so I guess it would make sense to also change that.
This does not have any impact on calculations or comparisons, this is purely visual but can lead to unexpected behavior if the returned number is used as a string (e.g. substr, strtok,...) since there suddenly is an additional character in front of the numbers.
This is especially unexpected, when the float is the result of float arithmetics, which can minimally negative numbers in some cases
PHP Version
8.4
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンクされた 3v4l の例を PHP 8.4 で再現し、その後、signed zero を処理する min() と max() のエントリポイントを追跡します。意図された修正が -0 を保持するのか、0 に正規化するのかを判断し、報告された呼び出しに対するリグレッションカバレッジで選択した動作を検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100