Negative power of zero¶
Description¶
It is not possible to calculate a negative power of 0: a negative power is, in fact, a division raised to a power, and division by zero is undefined.
It was a silent error until PHP 8.4, and it is now a visible one.
This is also the case with PHP native **
and pow().
Example¶
<?php
echo bcpow(0, -1);
?>
Solutions¶
Check for the first argument not to be 0, or similar.
Catch the exception.