Bug #78606 [NEW]: Wrong calculation when dealing with bigint
| From: | marcelotpcruz at gmail dot com | Date: | Sun, 29 Sep 2019 02:55:11 +0000 |
| Subject: | Bug #78606 [NEW]: Wrong calculation when dealing with bigint | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222939@lists.php.net to get a copy of this message | ||
From: marcelotpcruz at gmail dot com
Operating system: Windows/Unix
PHP version: 7.3.10
Package: Math related
Bug Type: Bug
Bug description:Wrong calculation when dealing with bigint
Description:
------------
Using a 64 bit install on a 64 bit system:
Test script:
---------------
<?php
$someInt = 36028797018963968;//2^55
echo $someInt . '<br>';
echo number_format($someInt, 10, '.', '') . '<br>';
$someInt-= 10;
if((PHP_INT_MAX + 1) === (PHP_INT_MAX + 2)) //This should be false
echo 'This should never be echoed<br>';
echo number_format($someInt, 10, '.', '') . '<br>';//Value here
is just
$someInt minus 10
$maxInt = PHP_INT_MAX;
echo $maxInt . '<br>';
echo ++$maxInt . '<br>';
echo --$maxInt . '<br>';//Should print 9223372036854775807
echo number_format(PHP_INT_MAX, 0, '.', '') . '<br>';//Should
print
9223372036854775807
Expected result:
----------------
36028797018963968
36028797018963968.0000000000
36028797018963958.0000000000
9223372036854775807
9.2233720368548E+18
9223372036854775807
9223372036854775807
Actual result:
--------------
36028797018963968
36028797018963968.0000000000
This should never be echoed
36028797018963960.0000000000
9223372036854775807
9.2233720368548E+18
9.2233720368548E+18
9223372036854775808
--
Edit bug report at https://bugs.php.net/bug.php?id=78606&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78606&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78606&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78606&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78606&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78606&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78606&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78606&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78606&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78606&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78606&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78606&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78606&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78606&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78606&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78606&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78606&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78606&r=mysqlcfg