Bug #67478 [NEW]: Strange behaviour on casting to integer
| From: | upyx dot 00 at gmail dot com | Date: | Thu, 19 Jun 2014 12:42:42 +0000 |
| Subject: | Bug #67478 [NEW]: Strange behaviour on casting to integer | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186256@lists.php.net to get a copy of this message | ||
From: upyx dot 00 at gmail dot com
Operating system: linux 64
PHP version: 5.5.13
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Strange behaviour on casting to integer
Description:
------------
Returns huge negative value when casting float value greater then
PHP_INT_MAX to integer.
Test script:
---------------
$ php -r 'var_dump(9223372036854775808);'
double(9.2233720368548E+18)
$ php -r 'var_dump((int)9223372036854775808);'
int(-9223372036854775808)
$ php -r 'var_dump((int)9223372036854775809);'
int(-9223372036854775808)
Expected result:
----------------
double(9.2233720368548E+18)
ERROR (or cut to PHP_INT_MAX, but not negative value!)
ERROR
Actual result:
--------------
double(9.2233720368548E+18)
int(-9223372036854775808)
int(-9223372036854775808)
--
Edit bug report at https://bugs.php.net/bug.php?id=67478&edit=1
--