mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-27 00:58:25 +00:00
Negative numbers should be prepended with a 0
This commit is contained in:
parent
0f95ddc692
commit
c2c3e9420d
@ -611,7 +611,13 @@ class Math_BigInteger {
|
|||||||
if ($start) { // hexdec('') == 0
|
if ($start) { // hexdec('') == 0
|
||||||
$bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT) . $bits;
|
$bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT) . $bits;
|
||||||
}
|
}
|
||||||
return $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0');
|
$result = $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0');
|
||||||
|
|
||||||
|
if ($twos_compliment && $this->compare(new Math_BigInteger()) > 0 && $this->precision <= 0) {
|
||||||
|
return '0' . $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user