[php-src] Issue #20221: max/min return wrong value if signed (negative) zero

From: Date: Sun, 19 Oct 2025 09:20:57 +0000
Subject: [php-src] Issue #20221: max/min return wrong value if signed (negative) zero
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251085@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20221 Author: kkmuffme ### Description The following code: https://3v4l.org/JXU4T#v8.4.13 ```php <?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 ```plain 8.4 ``` ### Operating System _No response_

« previous php.bugs (#251085) next »