Repository navigation
Explain why -9223372036854775808 is a float, not PHP_INT_MIN - #6092
Merged
lacatoire merged 1 commit intoNov 16, 2026
Merged
Conversation
A negative int literal is a positive literal with the negation operator applied to it. The literal 9223372036854775808 is beyond PHP_INT_MAX on 64-bit systems, so it is already a float when it is negated, and -9223372036854775808 === PHP_INT_MIN is false. The same happens with -2147483648 on 32-bit systems. Add a paragraph and an example to the integer overflow section that explain this and point to PHP_INT_MIN, or an expression such as -9223372036854775807 - 1, instead. The example output was checked on PHP 7.4, 8.5 and 8.6. Fixes php#2400
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A negative
intliteral is a positive literal with the negation operator applied to it. In-9223372036854775808, the literal9223372036854775808is beyondPHP_INT_MAXon 64-bit systems, so it is already afloatwhen it gets negated, and-9223372036854775808 === PHP_INT_MINisfalse(the same happens with-2147483648on 32-bit systems). The integer page says nothing about this, which is what #2400 ran into.This adds a paragraph and an example to the "Integer overflow" section that explain it and point to
PHP_INT_MIN, or an expression such as-9223372036854775807 - 1, instead. The example output was checked on PHP 7.4, 8.5 and 8.6.configure.phpand docbook-cs pass locally.Fixes #2400