mirror of
https://github.com/danog/PHPStruct.git
synced 2024-12-02 09:17:53 +01:00
Merge branch 'master' of https://github.com/danog/rightpack
This commit is contained in:
commit
7da0d5c924
@ -693,8 +693,8 @@ class StructTools
|
|||||||
if ($negative) {
|
if ($negative) {
|
||||||
$concat = $this->binadd($this->stringnot($concat), '1');
|
$concat = $this->binadd($this->stringnot($concat), '1');
|
||||||
}
|
}
|
||||||
if(strlen($concat) == $length + 1 && $concat == str_pad("1", $length + 1, '0', STR_PAD_RIGHT)){
|
if (strlen($concat) == $length + 1 && $concat == str_pad('1', $length + 1, '0', STR_PAD_RIGHT)) {
|
||||||
$concat = str_pad("", $length, "0");
|
$concat = str_pad('', $length, '0');
|
||||||
}
|
}
|
||||||
if (strlen($concat) > $length) {
|
if (strlen($concat) > $length) {
|
||||||
trigger_error('Converted binary number is too long ('.strlen($concat).' > '.$length.').');
|
trigger_error('Converted binary number is too long ('.strlen($concat).' > '.$length.').');
|
||||||
@ -716,7 +716,7 @@ class StructTools
|
|||||||
public function bindec($binary, $unsigned = true)
|
public function bindec($binary, $unsigned = true)
|
||||||
{
|
{
|
||||||
$decimal = 0;
|
$decimal = 0;
|
||||||
if (!$unsigned && $binary[0] == "1") {
|
if (!$unsigned && $binary[0] == '1') {
|
||||||
$binary = $this->binadd($this->stringnot($binary), '1');
|
$binary = $this->binadd($this->stringnot($binary), '1');
|
||||||
$negative = true;
|
$negative = true;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user