#49071 [Opn->Bgs]: gmp_intval returns bad value
| From: | jani@php.net | Date: | Tue, 28 Jul 2009 16:17:59 +0000 |
| Subject: | #49071 [Opn->Bgs]: gmp_intval returns bad value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140374@lists.php.net to get a copy of this message | ||
ID: 49071
Updated by: jani@php.net
Reported By: erha at freemail dot hu
-Status: Open
+Status: Bogus
Bug Type: GNU MP related
Operating System: windows
PHP Version: 5.2.10
New Comment:
RTFM, http://php.net/gmp_intval
"Warning
This function returns a useful result only if the number actually fits
the PHP integer (i.e., signed long type). If you want just to print the
GMP number, use gmp_strval()."
Previous Comments:
------------------------------------------------------------------------
[2009-07-27 10:59:15] erha at freemail dot hu
Description:
------------
In the following code gmp_intval returns bad results. Replace it with
gmp_strval to see the difference:
Reproduce code:
---------------
$val = "19991231235958";
$value = gmp_init($val);
$res = gmp_div_qr($value, "0x100000000");
$b1 = (string) gmp_intval($res[1]);
$b2 = (string) gmp_intval($res[0]);
echo "$b1 $b2";
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49071&edit=1