mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 03:42:40 +00:00
Merge branch '1.0' into 2.0
This commit is contained in:
commit
fae6542efc
@ -2694,7 +2694,14 @@ class BigInteger
|
|||||||
{
|
{
|
||||||
switch (MATH_BIGINTEGER_MODE) {
|
switch (MATH_BIGINTEGER_MODE) {
|
||||||
case self::MODE_GMP:
|
case self::MODE_GMP:
|
||||||
return gmp_cmp($this->value, $y->value);
|
$r = gmp_cmp($this->value, $y->value);
|
||||||
|
if ($r < -1) {
|
||||||
|
$r = -1;
|
||||||
|
}
|
||||||
|
if ($r > 1) {
|
||||||
|
$r = 1;
|
||||||
|
}
|
||||||
|
return $r;
|
||||||
case self::MODE_BCMATH:
|
case self::MODE_BCMATH:
|
||||||
return bccomp($this->value, $y->value, 0);
|
return bccomp($this->value, $y->value, 0);
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,9 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase
|
|||||||
// c < d
|
// c < d
|
||||||
$this->assertLessThan(0, $c->compare($d));
|
$this->assertLessThan(0, $c->compare($d));
|
||||||
$this->assertGreaterThan(0, $d->compare($c));
|
$this->assertGreaterThan(0, $d->compare($c));
|
||||||
|
|
||||||
|
$this->assertSame(-1, $this->getInstance(-999)->compare($this->getInstance(370)));
|
||||||
|
$this->assertSame(1, $this->getInstance(999)->compare($this->getInstance(-700)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBitwiseAND()
|
public function testBitwiseAND()
|
||||||
|
Loading…
Reference in New Issue
Block a user