note 48596 deleted from function.pow by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 15:30:21 +0000 |
| Subject: | note 48596 deleted from function.pow by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189865@lists.php.net to get a copy of this message | ||
Note Submitter: louis [at] mulliemedia.com
----
Here's a pow() function that allows negative bases :
<?php
function npow($base, $exp)
{
$result = pow(abs($base), $exp);
if ($exp % 2 !== 0) {
$result = - ($result);
}
return $result;
}
?>