This commit is contained in:
Petr Pucil 2020-04-27 23:25:47 +02:00
parent 37d3c319d9
commit 2b39ce9bc8
1 changed files with 2 additions and 4 deletions

View File

@ -307,11 +307,9 @@ namespace Kaitai
// raw mask with required number of 1s, starting from lowest bit
ulong mask = GetMaskOnes(n);
// shift mask to align with highest bits available in "bits"
// shift "bits" to align the highest bits with the mask & derive reading result
int shiftBits = BitsLeft - n;
mask = mask << shiftBits;
// derive reading result
ulong res = (Bits & mask) >> shiftBits;
ulong res = (Bits >> shiftBits) & mask;
// clear top bits that we've just read => AND with 1s
BitsLeft -= n;
mask = GetMaskOnes(BitsLeft);