Bug #78354 [NEW]: Literal int64 min is treated as a float

From: Date: Tue, 30 Jul 2019 15:30:26 +0000
Subject: Bug #78354 [NEW]: Literal int64 min is treated as a float
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222016@lists.php.net to get a copy of this message
From:             dktapps at pmmp dot io
Operating system: Windows 10
PHP version:      7.3.7
Package:          *General Issues
Bug Type:         Bug
Bug description:Literal int64 min is treated as a float

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 bug report at https://bugs.php.net/bug.php?id=78354&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=78354&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=78354&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=78354&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=78354&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=78354&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=78354&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=78354&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=78354&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=78354&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=78354&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78354&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=78354&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=78354&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=78354&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=78354&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=78354&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=78354&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#222016) next »