Doc #78081 [Dup]: Cannot write literal -9223372036854775808, do -922..807 - 1 instead
| From: | cmb@php.net | Date: | Wed, 29 May 2019 08:21:57 +0000 |
| Subject: | Doc #78081 [Dup]: Cannot write literal -9223372036854775808, do -922..807 - 1 instead | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16689@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78081&edit=1
ID: 78081
Updated by: cmb@php.net
Reported by: memory dot agape at gmail dot com
Summary: Cannot write literal -9223372036854775808, do
-922..807 - 1 instead
Status: Duplicate
Type: Documentation Problem
Package: Variables related
Operating System: MacOS
PHP Version: 7.2.18
Block user comment: N
Private report: N
New Comment:
See also <https://github.com/php/php-src/blob/31a516cf967e7558f0e06c2390fa9521309ed8b4/ext/standard/var.c#L490-L491>.
Previous Comments:
------------------------------------------------------------------------
[2019-05-29 07:55:23] bwoebi@php.net
This behavior is somewhat known, also do write PHP_INT_MIN instead.
But yeah, I consider this somewhat unfortunate (especially in generated code, where I ended up
having to write an explicit condition for if min value, then print PHP_INT_MIN, else the value...).
This should really be fixed in PHP itself, I think...
But for now marking as a dupe of #53934.
------------------------------------------------------------------------
[2019-05-29 07:00:36] requinix@php.net
I don't see it mentioned anywhere. I'd at least expect a note on the integers page.
------------------------------------------------------------------------
[2019-05-29 06:41:21] requinix@php.net
...I don't know. Last time I remember this coming up it was from a bug report - in fact within
the last month or so, I think.
------------------------------------------------------------------------
[2019-05-29 06:26:30] memory dot agape at gmail dot com
Thank you for your quick reply!
Is it information written in some document?
------------------------------------------------------------------------
[2019-05-29 06:10:29] requinix@php.net
This is a quirk of how PHP parses code: -1 is actually the number 1 negated, and since
-9223372036854775808 is too large for a positive integer it overflows to float and *then* is
negated.
You cannot write -9223372036854775808 as a literal. Write -9223372036854775807 - 1 instead.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=78081
--
Edit this bug report at https://bugs.php.net/bug.php?id=78081&edit=1