php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43981 gmp_div_r does not preserve the sign of 1st argument
Submitted: 2008-01-30 07:07 UTC Modified: 2008-01-30 18:27 UTC
From: ikr at xiag dot ch Assigned:
Status: Closed Package: Math related
PHP Version: 5.2.5 OS: Linux 2.6.22.13-0.3-default SMP
Private report: No CVE-ID: None
 [2008-01-30 07:07 UTC] ikr at xiag dot ch
Description:
------------
PHP manual at http://ch2.php.net/manual/en/function.gmp-div-r.php claims 
for gmp_div_r:

-----
resource gmp_div_r ( resource $n , resource $d [, int $round ] )
Calculates remainder of the integer division of n by d . The remainder 
has the sign of the n argument, if not zero.
-----

However,

print(gmp_strval(gmp_div_r(-5, 100)) . "\n");

Will result in "5", not "-5".

Reproduce code:
---------------
<?php

print(gmp_strval(gmp_div_r(-5, 100)) . "\n");

?>

Expected result:
----------------
-5

Actual result:
--------------
5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-30 18:27 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Feb 08 02:05:49 2023 UTC