Skip to content

Commit

Permalink
Work around gmp_pow behavior change
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Nov 14, 2024
1 parent 75ffba9 commit b937674
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/MaxMind/Db/Test/Reader/DecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,14 @@ public function generateLargeUint(int $bits): array

for ($power = 1; $power <= $bits / 8; ++$power) {
if (\extension_loaded('gmp')) {
$expected = gmp_strval(gmp_sub(gmp_pow('2', 8 * $power), '1'));
// This is to work around the limit added to gmp_pow here:
// https://github.com/php/php-src/commit/e0a0e216a909dc4ee4ea7c113a5f41d49525f02e
$v = 1;
for ($i = 0; $i < $power; $i++) {
$v = gmp_mul($v, 256);
}

$expected = gmp_strval(gmp_sub($v, '1'));
} elseif (\extension_loaded('bcmath')) {
$expected = bcsub(bcpow('2', (string) (8 * $power)), '1');
} else {
Expand Down

0 comments on commit b937674

Please sign in to comment.