Merge branch '2.0'

This commit is contained in:
terrafrost 2018-01-22 07:26:57 -06:00
commit 44ac8f3996
3 changed files with 14 additions and 1 deletions

View File

@ -387,7 +387,7 @@ class GMP extends Engine
public function bitwise_xor(GMP $x)
{
$temp = new self();
$temp->value = $this->value ^ $x->value;
$temp->value = gmp_abs($this->value) ^ gmp_abs($x->value);
return $this->normalize($temp);
}

View File

@ -938,6 +938,7 @@ abstract class PHP extends Engine
{
$length = max(count($this->value), count($x->value));
$result = clone $this;
$result->is_negative = false;
$result->value = array_pad($result->value, $length, 0);
$x->value = array_pad($x->value, $length, 0);

View File

@ -198,6 +198,18 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase
$z = $this->getInstance('BC98BC98BC98BC98BC98BC98', 16);
$this->assertSame($z->toHex(), $x->bitwise_XOR($y)->toHex());
// @group github1245
$a = $this->getInstance(1);
$b = $this->getInstance(-2);
$c = $a->bitwise_xor($b);
$this->assertSame("$c", '3');
$a = $this->getInstance('-6725760161961546982');
$b = $this->getInstance(51);
$c = $a->bitwise_xor($b);
$this->assertSame("$c", '6725760161961546965');
}
public function testBitwiseNOT()