ID:               27258
 Updated by:       [EMAIL PROTECTED]
 Reported By:      oscar at the-rileys dot net
-Status:           Open
+Status:           Assigned
-Bug Type:         Unknown/Other Function
+Bug Type:         Math related
 Operating System: NetBSD 1.6
-PHP Version:      5CVS-2004-02-15 (dev)
+PHP Version:      4CVS,5CVS
-Assigned To:      
+Assigned To:      iliaa


Previous Comments:
------------------------------------------------------------------------

[2004-02-15 01:17:52] oscar at the-rileys dot net

I neglected to mention that this is vs. CVS snapshot 

200402142230.  The original bugfix that caused the 

problem was submitted on 2/8/04.

------------------------------------------------------------------------

[2004-02-15 01:14:04] oscar at the-rileys dot net

Description:
------------
The fix for bug #27172 (possible floating-point 

exception in gmp_powm) breaks the function with modulos 

longer than 31 bits.  This is because the modulo 

argument is converted (destructively) to a long before 

it is fetched as a GMP number.  The problem is rectified 

by moving the block that checks for a zero modulo to a 

point after the argument is fetched for use in the 

function.



I have posted a diff here:



http://oscar.the-rileys.net/php5-gpm_powm-patch.diff



I have tested this on my own server, and it appears to 

fix the problem with at least 1024-bit modulos and still 

guards against 0 modulos - test for yourself to be sure, 

of course,

Reproduce code:
---------------
This is the example code from the documentation page for gpm_powm:



<?php

   $pow1 = gmp_powm("2", "31", "2147483649");

   echo gmp_strval($pow1) . "\n";

?>

Expected result:
----------------
The number 2147483648 should be output.

Actual result:
--------------
The number 1 is output.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27258&edit=1

Reply via email to