Skip to content

Commit a3b267d

Browse files
committed
Fix BcMathCalculator::pow() returning '0' for 0^0
Not currently reachable via the public API (power() short-circuits a zero exponent), but realigns BcMath with GmpCalculator, NativeCalculator, and bcpow() itself.
1 parent c76b280 commit a3b267d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/Internal/Calculator/BcMathCalculator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public function divQR(string $a, string $b): array
6565
#[Override]
6666
public function pow(string $a, int $e): string
6767
{
68+
if ($e === 0) {
69+
return '1';
70+
}
71+
6872
// bcpow() allocates memory proportional to the exponent even when the base is trivial,
6973
// exhausting memory on 32-bit builds at large exponents.
7074
if ($a === '0' || $a === '1') {

0 commit comments

Comments
 (0)