From d31d8fecd865654868dea946b8eed4d24a66d29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0tefa=C5=88=C3=A1k?= Date: Sat, 24 Oct 2020 12:09:47 +0200 Subject: [PATCH] Fixed direction of negative tiny_int https://7687.org/packstream/packstream-specification-1.html#integer --- PackStream/v1/Unpacker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PackStream/v1/Unpacker.php b/PackStream/v1/Unpacker.php index 740b02b..8ec7729 100644 --- a/PackStream/v1/Unpacker.php +++ b/PackStream/v1/Unpacker.php @@ -268,7 +268,7 @@ private function unpackInteger(int $marker, bool &$result = false): int if ($marker >> 7 == 0b0) { //+TINY_INT $output = $marker; } elseif ($marker >> 4 == 0b1111) { //-TINY_INT - $output = 0b11110000 ^ $marker; + $output = -16 + (0b11110000 ^ $marker); } elseif ($marker == 0xC8) { //INT_8 $output = unpack('c', $this->next(1))[1] ?? 0; } elseif ($marker == 0xC9) { //INT_16