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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
40 + 24 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC