Bug #53934 [Com]: The negative PHP_INT_MAX is incorrectly converted to float

From: Date: Tue, 29 May 2018 12:18:52 +0000
Subject: Bug #53934 [Com]: The negative PHP_INT_MAX is incorrectly converted to float
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215411@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53934&edit=1 ID: 53934 Comment by: spam2 at rhsoft dot net Reported by: eriksen dot costa at infranology dot com dot br Summary: The negative PHP_INT_MAX is incorrectly converted to float Status: Verified Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: come on, explain me why the large number becomes a float when we all known from hundrets of bugrports that float values are making nothing than trouble swhen you touch or even echo them in doubt php > $x = 9223372036854775808; php > echo is_float($x); 1 php > $x = 922337203685477; php > echo is_float($x); php > echo is_int($x); 1 Previous Comments: ------------------------------------------------------------------------ [2018-05-29 12:16:00] spam2 at rhsoft dot net hell, there are a ton of problems - when a constant named with INT on a x86_64 fails is_int() something is seriously broken - @cmb: as you can see with -100 the minus sign is not problem PHP_INT_MIN and PHP_INT_MAX a *both float* which is wrong - period php > $x = -100; php > echo is_int($x); 1 php > $x = 9223372036854775808; php > echo is_float($x); 1 php > echo is_int($x); php > php > echo PHP_INT_MAX; 9223372036854775807 php > echo PHP_INT_MIN; -9223372036854775808 php > $x = -9223372036854775808; php > echo is_int($x); php > $x = 9223372036854775808; php > echo is_int($x); php > echo is_int(1); 1 php > $x = 1000; php > echo is_int($x); 1 php > ------------------------------------------------------------------------ [2018-05-29 11:41:13] cmb@php.net In my opinion, this is not a bug, but rather a documentation issue. PHP (as many other languages, I believe) does not support signed literals, but rather only unsigned literals plus the identity and negation operators. If we would introduce the notion of signed integer literals, there would be a difference between -9223372036854775808 and 0-9223372036854775808 – that's even more confusing. ------------------------------------------------------------------------ [2018-05-29 11:25:41] cmb@php.net Related To: Bug #76385 ------------------------------------------------------------------------ [2017-08-02 17:05:36] nikic@php.net Related To: Bug #75026 ------------------------------------------------------------------------ [2015-12-19 23:27:49] ajf at ajf dot me Since PHP 7 there is PHP_INT_MIN for this purpose, by the way. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=53934 -- Edit this bug report at https://bugs.php.net/bug.php?id=53934&edit=1

« previous php.bugs (#215411) next »