1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-11-26 20:35:21 +01:00

BigInteger: backport GMP fixes from master branch

This commit is contained in:
terrafrost 2019-05-26 15:38:18 -05:00
parent 8b76e96b83
commit 677ae387b0
2 changed files with 4 additions and 1 deletions

View File

@ -441,7 +441,7 @@ class Math_BigInteger
// (?<=^|-)0*: find any 0's that are preceded by the start of the string or by a - (ie. octals)
// [^-0-9].*: find any non-numeric characters and then any characters that follow that
$x = preg_replace('#(?<!^)(?:-).*|(?<=^|-)0*|[^-0-9].*#', '', $x);
if (!strlen($x)) {
if (!strlen($x) || $x == '-') {
$x = '0';
}

View File

@ -414,5 +414,8 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase
{
$temp = $this->getInstance('00');
$this->assertSame($temp->toString(), '0');
$temp = $this->getInstance('-0');
$this->assertSame($temp->toString(), '0');
}
}