Bug #71816 [NEW]: Assigning literal equivalent of PHP_INT_MIN results in double

From: Date: Mon, 14 Mar 2016 02:26:13 +0000
Subject: Bug #71816 [NEW]: Assigning literal equivalent of PHP_INT_MIN results in double
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199800@lists.php.net to get a copy of this message
From:             patrick at patrickmcdougle dot com
Operating system: Ubuntu Server 64-bit
PHP version:      7.0.4
Package:          *General Issues
Bug Type:         Bug
Bug description:Assigning literal equivalent of PHP_INT_MIN results in double

Description:
------------
Assigning a variable the PHP_INT_MIN literal to a variable results in a
double instead of an integer. I would expect the min representable
integer to remain an integer. See below.

Test script:
---------------
vagrant@vagrant-ubuntu-trusty-64:~$ php -v
PHP 7.0.4-1+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend
Technologies
vagrant@vagrant-ubuntu-trusty-64:~$ php -a
Interactive mode enabled

php > echo PHP_INT_MIN; 
-9223372036854775808
php > $foo = -9223372036854775808;
php > print_r($foo); 
-9.2233720368548E+18
php > echo gettype($foo); 
double
php > $foo = -9223372036854775807;
php > print_r($foo);
-9223372036854775807
php > echo gettype($foo);
integer


-- 
Edit bug report at https://bugs.php.net/bug.php?id=71816&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71816&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71816&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71816&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71816&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71816&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71816&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71816&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71816&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71816&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71816&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71816&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71816&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71816&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71816&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71816&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71816&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71816&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71816&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71816&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71816&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#199800) next »