Note Submitter: Merve

----

If you want to calculate powers, but you're having trouble with negative numbers and zero, use this code. It's still not compatible with a decimal number as the power (I'm working on that, but I doubt I'll ever be able to). All you have to do is include a bunch of if-then statements, along with the while loop. For those of you unfamiliar with special characters &#61; is = and <sup> puts your stuff in superscript.

<?php
if ($b==0) {
print (" $a<sup>$b</sup> &#61; 1");
}
elseif ($b<0) {
$c = $a;
$d = $b;
$f = ($b*-1);
while ($f>1)
{
$a = ($a*$c);
$f--;
}
$e = (1/$a);
print (" $c<sup>$d</sup> &#61; $e");
} else {
$c = $a;
$d = $b;
while ($b>1)
{
$a = ($a*$c);
$b--;
}
print (" $c<sup>$d</sup> &#61; $a");
}
}
?>

So, making your calculator will be a cinch.