aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/BinaryFormat/Decoder.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/BinaryFormat/Decoder.php')
-rw-r--r--src/BinaryFormat/Decoder.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/BinaryFormat/Decoder.php b/src/BinaryFormat/Decoder.php
index 30c5b56..c61fade 100644
--- a/src/BinaryFormat/Decoder.php
+++ b/src/BinaryFormat/Decoder.php
@@ -1052,10 +1052,14 @@ final class Decoder
$shiftBits += 7;
if ($b < 0b10000000) {
if (($b & 0b01000000) !== 0) {
- if ($shiftBits < $bits - 1) {
- $result |= -(1 << $shiftBits);
+ if ($bits === 32) {
+ $result |= (-1) ^ (1 << $shiftBits) - 1;
} else {
- $result |= 1 << $shiftBits;
+ if ($shiftBits < $bits - 1) {
+ $result |= -(1 << $shiftBits);
+ } else {
+ $result |= 1 << $shiftBits;
+ }
}
}
return $result;