Bug #78354 [Opn->Dup]: Literal int64 min is treated as a float
Edit report at https://bugs.php.net/bug.php?id=78354&edit=1
ID: 78354
Updated by: requinix@php.net
Reported by: dktapps at pmmp dot io
Summary: Literal int64 min is treated as a float
-Status: Open
+Status: Duplicate
Type: Bug
Package: *General Issues
Operating System: Windows 10
PHP Version: 7.3.7
Block user comment: N
Private report: N
New Comment:
See bug #78081.
Use PHP_INT_MIN instead.
Previous Comments:
------------------------------------------------------------------------
[2019-07-30 15:30:26] dktapps at pmmp dot io
Description:
------------
On 64-bit PHP, hardcoding the literal -9223372036854775808 or
-0x8000000000000000 produces a float instead of an int. This appears to be some kind of
parser bug, because introducing a subtraction into the mix avoids the problem (see below).
Test script:
---------------
<?php
var_dump(-9223372036854775808);
var_dump(-9223372036854775807 - 1);
var_dump(-0x8000000000000000);
var_dump(-0x7fffffffffffffff - 1);
Expected result:
----------------
int(-9223372036854775808)
int(-9223372036854775808)
int(-9223372036854775808)
int(-9223372036854775808)
Actual result:
--------------
float(-9.2233720368548E+18)
int(-9223372036854775808)
float(-9.2233720368548E+18)
int(-9223372036854775808)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78354&edit=1
Thread (2 messages)