BigInteger/GMP: negative base-256 numbers didn't load correctly

This commit is contained in:
terrafrost 2019-04-09 20:42:18 -05:00
parent 114dc17f5b
commit 31c10f39e5

View File

@ -136,8 +136,10 @@ class GMP extends Engine
{ {
switch (abs($base)) { switch (abs($base)) {
case 256: case 256:
$sign = $this->is_negative ? '-' : '';
$this->value = gmp_import($this->value); $this->value = gmp_import($this->value);
if ($this->is_negative) {
$this->value = -$this->value;
}
break; break;
case 16: case 16:
$temp = $this->is_negative ? '-0x' . $this->value : '0x' . $this->value; $temp = $this->is_negative ? '-0x' . $this->value : '0x' . $this->value;