We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7a9fe3f commit 3cd26ebCopy full SHA for 3cd26eb
kaitaistruct.py
@@ -237,11 +237,9 @@ def read_bits_int_be(self, n):
237
238
# raw mask with required number of 1s, starting from lowest bit
239
mask = (1 << n) - 1
240
- # shift mask to align with highest bits available in self.bits
+ # shift self.bits to align the highest bits with the mask & derive reading result
241
shift_bits = self.bits_left - n
242
- mask <<= shift_bits
243
- # derive reading result
244
- res = (self.bits & mask) >> shift_bits
+ res = (self.bits >> shift_bits) & mask
245
# clear top bits that we've just read => AND with 1s
246
self.bits_left -= n
247
mask = (1 << self.bits_left) - 1
0 commit comments