I hate every living thing that ever lived, except for Ms. A.Sh.O. and maybe also Ms. C.D.F. I hate the person who posted the silly joke below my post, and I hate myself immeasurably more.
That having been said:
This function takes arbitrary integers as exponents:
<?php
function bcpowislame($base,$exp,$scale) {
$wexp=bcadd($exp,'0',0);
if (bccomp($exp,$wexp)) return false;
$wbase=$base; $wscale=$scale+strlen($wexp)+3; if ($wexp{0}=='-')
{$wbase=bcdiv('1',$wbase,$wscale); $wexp=bcsub('0',$wexp,0);}
if ($wexp=='0') return bcadd('1','0',$scale);
$scr='1'; $scrm=$wbase; $loop=true;
while ($loop) {
if (bcmod($wexp,'2')=='1') $scr=bcmul($scr,$scrm,$wscale);
if (bccomp($wexp,'1')==0) $loop=false;
else {$scrm=bcmul($scrm,$scrm,$wscale); $wexp=bcdiv($wexp,'2',0);}}
return bcadd('0',$scr,$scale); }
?>
I also hate my interpreter for not letting this work on negative exponents.
This seems to work great on positive exponents though.