Peter

Peter

  • NA
  • 1
  • 0

Calculating a 4-byte value when MSBs are set to 0

Nov 8 2005 7:19 AM
Hi there

In a program I am writing I am reading in a stream of bytes from a file.  In order to do this I need to know the length of the stream to read into an array.

The size of the stream is given in the stream header as a 4-byte number... Normally this would be easy to work out, however the MSB [bit 7] of all 4 bytes have been set to 0 for unsynchronisation purposes [the stream is an ID3 tag from an .MP3].

My experience of manipulating bits and bytes is very limited and so I have no real idea of how to go about calculating the number.

I do know that the bitshift operators will come into it [>> and <<] but so far everything I have tried has come up short.

Any clues?

Thanks for taking the time to read this post.

Regards

Aeternum