Title: max/min return wrong value if signed (negative) zero · Issue #20221 · php/php-src · GitHub
Open Graph Title: max/min return wrong value if signed (negative) zero · Issue #20221 · php/php-src
X Title: max/min return wrong value if signed (negative) zero · Issue #20221 · php/php-src
Description: Description The following code: https://3v4l.org/JXU4T#v8.4.13
Open Graph Description: Description The following code: https://3v4l.org/JXU4T#v8.4.13
X Description: 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) flo...
Opengraph URL: https://github.com/php/php-src/issues/20221
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"max/min return wrong value if signed (negative) zero","articleBody":"### Description\n\nThe following code:\n\nhttps://3v4l.org/JXU4T#v8.4.13\n\n```php\n\u003c?php\nvar_dump( min( round( -0.01 / 2, 0 ), 0 ) );\nvar_dump( max( round( -0.01 / 2, 0 ), 0 ) );\n```\n\nResulted in this output:\n```\nint(0)\nfloat(-0)\n```\n\nBut I expected this output instead:\n```\nfloat(-0)\nint(0)\n```\n\nFor 99.9% of applications, this output is actually what people would expect however: (instead of `-0`)\n```\nfloat(0)\nint(0)\n```\n\nso I guess it would make sense to also change that.\n\nThis 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.\nThis is especially unexpected, when the float is the result of float arithmetics, which can minimally negative numbers in some cases\n\n### PHP Version\n\n```plain\n8.4\n```\n\n### Operating System\n\n_No response_","author":{"url":"https://github.com/kkmuffme","@type":"Person","name":"kkmuffme"},"datePublished":"2025-10-19T09:20:55Z","url":"https://github.com/php/php-src/issues/20221"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bb06bd10-d5c5-e3df-d610-20f657bba877 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C726:2A01CD:41988D:5CAE1F:6B0072AB |
| html-safe-nonce | 2a9ca027d535898590b380bce78cf4576aafa3c653bd23a5bc529dbfacc5b740 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzI2OjJBMDFDRDo0MTk4OEQ6NUNBRTFGOjZCMDA3MkFCIiwidmlzaXRvcl9pZCI6IjgyNjUzNjU0NjU3MTk2NjUzMjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fde122215db7c21274375b72a6c8d0e8c52c91356f5fc71dcdc91d7df5182da3 |
| hovercard-subject-tag | issue:3529863672 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/php/php-src/20221/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d5ade1501c7145ccfb8a7652b64a7a0c239396bb71793718daf0bbee6b81b54f/php/php-src/issues/20221 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d5ade1501c7145ccfb8a7652b64a7a0c239396bb71793718daf0bbee6b81b54f/php/php-src/issues/20221 |
| og:image:alt | Description The following code: https://3v4l.org/JXU4T#v8.4.13 |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kkmuffme |
| hostname | github.com |
| expected-hostname | github.com |
| None | 75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16 |
| turbo-cache-control | no-preview |
| go-import | github.com/php/php-src git https://github.com/php/php-src.git |
| octolytics-dimension-user_id | 25158 |
| octolytics-dimension-user_login | php |
| octolytics-dimension-repository_id | 1903522 |
| octolytics-dimension-repository_nwo | php/php-src |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1903522 |
| octolytics-dimension-repository_network_root_nwo | php/php-src |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 84e563eb4b55f8fa102f325f117533cee9e3df4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width