php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49071 gmp_intval returns bad value
Submitted: 2009-07-27 10:59 UTC Modified: 2009-07-28 16:17 UTC
From: erha at freemail dot hu Assigned:
Status: Not a bug Package: GNU MP related
PHP Version: 5.2.10 OS: windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: erha at freemail dot hu
New email:
PHP Version: OS:

 

 [2009-07-27 10:59 UTC] 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";


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-28 16:17 UTC] jani@php.net
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()."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC