Bug #78081 [Opn->Nab]: I tried to output -9223372036854775808 but it will show -9.2233720368548E+18

From: Date: Wed, 29 May 2019 06:10:29 +0000
Subject: Bug #78081 [Opn->Nab]: I tried to output -9223372036854775808 but it will show -9.2233720368548E+18
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221037@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: requinix@php.net Reported by: memory dot agape at gmail dot com Summary: I tried to output -9223372036854775808 but it will show -9.2233720368548E+18 -Status: Open +Status: Not a bug Type: Bug -Package: *General Issues +Package: Scripting Engine problem Operating System: MacOS PHP Version: 7.2.18 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2019-05-29 05:59:30] memory dot agape at gmail dot com Description: ------------ I tried to output a negative value -9223372036854775808 but it will show a double type value. It expected an integer value. My PHP version is shown below: > php -v > PHP 7.2.18 (cli) (built: May 21 2019 20:18:44) ( NTS ) > Copyright (c) 1997-2018 The PHP Group > Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies > with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans > with Zend OPcache v7.2.18, Copyright (c) 1999-2018, by Zend Technologies Test script: --------------- <?php var_dump(PHP_INT_MIN); var_dump(-9223372036854775808); var_dump((int) -9223372036854775808); var_dump(-9223372036854775807); var_dump(PHP_INT_MAX); var_dump(9223372036854775807); ?> Expected result: ---------------- int(-9223372036854775808) int(-9223372036854775808) int(-9223372036854775808) int(-9223372036854775807) int(9223372036854775807) int(9223372036854775807) Actual result: -------------- int(-9223372036854775808) double(-9.2233720368548E+18) int(-9223372036854775808) int(-9223372036854775807) int(9223372036854775807) int(9223372036854775807) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78081&edit=1

« previous php.bugs (#221037) next »