mirror of
https://github.com/danog/PHPStruct.git
synced 2024-11-30 04:19:08 +01:00
Merge branch 'master' of https://github.com/danog/rightpack
This commit is contained in:
commit
7da0d5c924
@ -419,8 +419,8 @@ class StructTools
|
||||
if (!is_int($result[$arraycount]) && !is_float($result[$arraycount])) {
|
||||
$result[$arraycount] = (int) $result[$arraycount];
|
||||
}
|
||||
if(is_float($result[$arraycount]) && $result[$arraycount] < PHP_INT_MAX) {
|
||||
$result[$arraycount] = (int)$result[$arraycount];
|
||||
if (is_float($result[$arraycount]) && $result[$arraycount] < PHP_INT_MAX) {
|
||||
$result[$arraycount] = (int) $result[$arraycount];
|
||||
}
|
||||
break;
|
||||
case 'float':
|
||||
@ -688,13 +688,13 @@ class StructTools
|
||||
do {
|
||||
$concat = ($number % 2).$concat;
|
||||
$number = intval($number / 2);
|
||||
} while($number > 0);
|
||||
} while ($number > 0);
|
||||
$concat = str_pad($concat, $length, '0', STR_PAD_LEFT);
|
||||
if ($negative) {
|
||||
$concat = $this->binadd($this->stringnot($concat), '1');
|
||||
}
|
||||
if(strlen($concat) == $length + 1 && $concat == str_pad("1", $length + 1, '0', STR_PAD_RIGHT)){
|
||||
$concat = str_pad("", $length, "0");
|
||||
if (strlen($concat) == $length + 1 && $concat == str_pad('1', $length + 1, '0', STR_PAD_RIGHT)) {
|
||||
$concat = str_pad('', $length, '0');
|
||||
}
|
||||
if (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)
|
||||
{
|
||||
$decimal = 0;
|
||||
if (!$unsigned && $binary[0] == "1") {
|
||||
if (!$unsigned && $binary[0] == '1') {
|
||||
$binary = $this->binadd($this->stringnot($binary), '1');
|
||||
$negative = true;
|
||||
} else {
|
||||
@ -812,7 +812,7 @@ class StructTools
|
||||
$bitnumber = $blocksize * 8;
|
||||
if ($unsigned) {
|
||||
$min = 0;
|
||||
switch($bitnumber) {
|
||||
switch ($bitnumber) {
|
||||
case '8':
|
||||
$max = 255;
|
||||
break;
|
||||
@ -830,7 +830,7 @@ class StructTools
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch($bitnumber) {
|
||||
switch ($bitnumber) {
|
||||
case '8':
|
||||
$min = -127;
|
||||
$max = 127;
|
||||
|
Loading…
Reference in New Issue
Block a user