Skip to content

How to find out the number of bits read from a stream or an array of bits? #252

Answered by scott-griffiths
Foxiks asked this question in Q&A
Discussion options

You must be logged in to vote

There is a pos attribute on bitstrings that support reading, which gives the current bit position. So you can look at stream.pos before and after a set of reads to see how much has been read. This isn't supported for the Bits or BitArray classes as you can't treat them like a stream.

So in short you can just use stream.pos to get a bit position.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Foxiks
Comment options

Answer selected by Foxiks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants