#45330 [Opn->Bgs]: Incorrect outcomes gmp_pow

From: Date: Wed, 21 Jan 2009 19:43:06 +0000
Subject: #45330 [Opn->Bgs]: Incorrect outcomes gmp_pow
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133125@lists.php.net to get a copy of this message
ID: 45330 Updated by: jani@php.net Reported By: duisters_k at hotmail dot com -Status: Open +Status: Bogus Bug Type: GNU MP related Operating System: Win XP SP2 PHP Version: 5.2.6 New Comment: RTFM. Proto of this function: resource gmp_pow ( resource $base , int $exp ) Notice the text 'int' for 2nd parameter? Previous Comments: ------------------------------------------------------------------------ [2008-06-24 15:49:01] duisters_k at hotmail dot com 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 ------------------------------------------------------------------------ [2008-06-22 17:08:21] pajoye@php.net 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

« previous php.bugs (#133125) next »