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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ikr at xiag dot ch
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC