php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78354 Literal int64 min is treated as a float
Submitted: 2019-07-30 15:30 UTC Modified: 2019-07-30 15:40 UTC
From: dktapps at pmmp dot io Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 7.3.7 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 + 18 = ?
Subscribe to this entry?

 
 [2019-07-30 15:30 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-30 15:38 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2019-07-30 15:38 UTC] requinix@php.net
See bug #78081.

Use PHP_INT_MIN instead.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC