Bug #78606 [Opn->Nab]: Wrong calculation when dealing with bigint

From: Date: Sun, 29 Sep 2019 08:32:16 +0000
Subject: Bug #78606 [Opn->Nab]: Wrong calculation when dealing with bigint
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222943@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78606&edit=1

 ID:                 78606
 Updated by:         cmb@php.net
 Reported by:        marcelotpcruz at gmail dot com
 Summary:            Wrong calculation when dealing with bigint
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Math related
 Operating System:   Windows/Unix
 PHP Version:        7.3.10
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

See <https://www.php.net/manual/en/language.types.integer.php#language.types.integer.overflow>
and <https://www.php.net/manual/en/language.types.float.php>.


Previous Comments:
------------------------------------------------------------------------
[2019-09-29 02:55:11] marcelotpcruz at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=78606&edit=1


Thread (4 messages)

« previous php.bugs (#222943) next »