Bug #79955 [NEW]: converting large floats to int leads to overflow or the arithmetical unit
| From: | peter dot fargas at informatik-handwerk dot de | Date: | Tue, 11 Aug 2020 20:20:05 +0000 |
| Subject: | Bug #79955 [NEW]: converting large floats to int leads to overflow or the arithmetical unit | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-228518@lists.php.net to get a copy of this message | ||
From: peter dot fargas at informatik-handwerk dot de
Operating system:
PHP version: 8.0.0beta1
Package: Math related
Bug Type: Bug
Bug description:converting large floats to int leads to overflow or the arithmetical unit
Description:
------------
(int](PHP_MAX_INT + 1) returns \PHP_INT_MIN.
Increasing the argument passed, zero result can be achieved.
Same goes for the \intval() function.
This happens for all current PHP versions - reported by
https://3v4l.org/iDnt4
7.2.0 - 7.2.33, 7.3.0 - 7.3.21, 7.4.0 - 7.4.9
8.0.0alpha1 - beta1
Test script:
---------------
<?php
echo '---- INTMAX vs INTMAX+1'. \PHP_EOL;
var_dump(\PHP_INT_MAX);
var_dump(\PHP_INT_MAX+1);
echo '---- INTMAX to float and back'. \PHP_EOL;
var_dump(\intval((float)\PHP_INT_MAX));
var_dump((int)((float)\PHP_INT_MAX));
echo '---- INTMAX+1 to float and back'. \PHP_EOL;
var_dump(\intval(\PHP_INT_MAX+1));
var_dump((int)(\PHP_INT_MAX+1));
var_dump(\PHP_INT_MIN);
echo '---- ...rendezvous point is...'. \PHP_EOL;
var_dump(\intval(18446744073709551615));
Expected result:
----------------
one of:
- \PHP_MAX_INT (just as the documentation states), a sign stable result
- type error
- zero
Actual result:
--------------
overflow or the arithmetical unit
--
Edit bug report at https://bugs.php.net/bug.php?id=79955&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79955&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79955&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79955&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79955&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79955&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79955&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79955&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79955&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79955&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79955&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79955&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79955&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79955&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79955&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79955&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79955&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79955&r=mysqlcfg