ID: 45330
User updated by: duisters_k at hotmail dot com
Reported By: duisters_k at hotmail dot com
-Status: Feedback
+Status: Open
Bug Type: Math related
Operating System: Win XP SP2
PHP Version: 5.2.6
New Comment:
Description:
------------
When I use gmp_init(), gmp_pow gives incorrect answers.
Reproduce code:
---------------
<pre><?php
$iMessage = 88;
$rText = gmp_init($iMessage);
$rRandE = gmp_init("7");
?>
Message: <?=gmp_strval($rText)?>
e: <?=gmp_strval($rRandE)?> <!-- 7 -->
Message^e:<?=gmp_strval(gmp_pow($rText,$rRandE))?>
88^7: <?=gmp_strval(gmp_pow(88,7))?>
pow(88,7):<?=pow(88,7)?>
Expected result:
----------------
Message: 88
e: 7
Message^e:40867559636992
88^7: 40867559636992
pow(88,7):40867559637000
Actual result:
--------------
Message: 88
e: 7
Message^e:18979061712307928304713728
88^7: 40867559636992
pow(88,7):40867559637000
Previous Comments:
------------------------------------------------------------------------
[2008-06-22 17:08:21] [EMAIL PROTECTED]
Can you give a comprehensible script without external values (no _GET)?
and a clear output of this script and what you would expect, no need to
comment it, only what the script outputs now and what you would like to
have.
------------------------------------------------------------------------
[2008-06-22 16:57:47] duisters_k at hotmail dot com
Description:
------------
When I use gmp_init(), gmp_pow gives incorrect answers.
Reproduce code:
---------------
<pre><?php
$iMessage = ord($_GET['message']);
$rText = gmp_init($iMessage);
$rRandE = gmp_init("7");
?>
Message: <?=gmp_strval($rText)?> <!-- 88 -->
e: <?=gmp_strval($rRandE)?> <!-- 7 -->
Message^e:<?=gmp_strval(gmp_pow($rText,$rRandE))?>
18979061712307928304713728
88^7: <?=gmp_strval(gmp_pow(88,7))?> 40867559636992 (It doesn't
matter here whether I use strings or integers)
pow(88,7):<?=pow(88,7)?> 40867559637000
Expected result:
----------------
Line 8 should give the same outcome as line 9 and (aproximatly) 10
Actual result:
--------------
Different outcomes
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45330&edit=1