Skip to content

Commit

Permalink
Merge branch '1.0' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Jun 20, 2019
2 parents 4903467 + 5e9d05a commit d2085db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion phpseclib/Math/BigInteger.php
Expand Up @@ -1561,7 +1561,9 @@ function divide($y)
$temp_value = array($quotient_value[$q_index]);
$temp = $temp->multiply($y);
$temp_value = &$temp->value;
$temp_value = array_merge($adjust, $temp_value);
if ($temp_value !== []) {
$temp_value = array_merge($adjust, $temp_value);
}

$x = $x->subtract($temp);

Expand Down Expand Up @@ -3582,6 +3584,7 @@ function _normalize($result)
$value = &$result->value;

if (!count($value)) {
$result->is_negative = false;
return $result;
}

Expand Down
16 changes: 16 additions & 0 deletions tests/Unit/Math/BigInteger/TestCase.php
Expand Up @@ -103,6 +103,22 @@ public function testDivide()

$this->assertSame('95627922070', (string) $q);
$this->assertSame('10688759725', (string) $r);

$x = $this->getInstance('3369993333393829974333376885877453834204643052817571560137951281152');
$y = $this->getInstance('4294967296');

list($q, $r) = $x->divide($y);

$this->assertSame('784637716923335095479473677900958302012794430558004314112', (string) $q);
$this->assertSame('0', (string) $r);

$x = $this->getInstance('3369993333393829974333376885877453834204643052817571560137951281153');
$y = $this->getInstance('4294967296');

list($q, $r) = $x->divide($y);

$this->assertSame('784637716923335095479473677900958302012794430558004314112', (string) $q);
$this->assertSame('1', (string) $r);
}

public function testModPow()
Expand Down

0 comments on commit d2085db

Please sign in to comment.