Feb-06-2021, 03:08 AM
(Jan-20-2021, 05:00 AM)bowlofred Wrote: So sounds like you want to treat the 4 bytes as a single 28-bit number. In that case I would:
* initialize total to zero
* starting with the high-order byte, loop over the four bytes
** shift the total left by 7 bits (total << 7)
** add the current byte & 127 to the total.
Okay, I get the concept but am having a problems translating it to code.
Just to make sure we are on the same page, I read 4 consecutive bytes (total of 32 bits) from
a file and I need to make a 28 bit number by removing the most significant bit from each byte.